Reputation: 1
Maybe someone can help me write test? This theme is difficult for me, i'll hope somebody explain that.
return axios.post("http://localhost:5000/login", {
login,
password,
});
};
export const loginThunk = (login, password) => (dispatch) => {
dispatch(fetchingAction(true));
fakeLoginRequest(login, password)
.then((response) => {
dispatch(fetchingAction(false));
if (response.data.isLoggedIn) {
dispatch(loginAction(login, password, response.data.isLoggedIn));
} else {
alert("Wrong login or password");
}
})
.catch((error) => {
dispatch(fetchingAction(false));
alert("cannot connect to server");
console.log(error);
});
};```
Upvotes: 0
Views: 135