I have a component class calling my service method:
const requestLogin = (username, password) => {
let response = authService.login(username, password);
console.log("test1");
console.log(response);
console.log("test2");
}
And here is the service method that making request to backend:
export function login(username, password) {
axios({
method: "post",
url: "http://localhost:8080/auth/login",
data: {username: username, password: password}
}).then(res => {
if (!res.ok) {
throw Error('Network Error'); //error from axios
}
return res.json();
}).catch(err => {
console.log(err.message) //to display the error to your user just use the useState to define your error
})
}
After that execution, actually backend is responding correctly and I see jwtToken from backend in Network tab, but in console I only see:
Where am I doing wrong ? I just want to check if the jwtToken is coming successfully and response code is 200 then I want to navigate to another page but why my debug console outputs showing this?