我认为我做的一切正确。但是程序在await is a reserved keyword
函数中显示“ signin
”。这是代码:
import axios from "axios";
const signin = async (username, password) => {
try {
console.log("Sign in function called");
const res = await axios.post(`${process.env.baseURL}/auth/signin`, {
username,
password
});
console.log(res.data);
} catch (error) {
console.log(error);
}
};
const logout = () => {
// remove user from local storage to log user out
localStorage.removeItem("jobmanager_user");
};
export const userService = {
signin,
logout
};