I want to save in localStorage my token from server(server it's made in java) but the code below doesn't work so I want to print res
too see what data do I get from server.
I tried to print to console with res.data.text()
and res.data.json()
but doesn't work.
return dispatch =>{
return api.user.login(userData).then(res =>{
const token = res.data;
console.log(token);
//localStorage.setItem('jwtToken',token);
})
}
import axios from 'axios'
export default {
user:{
login:(credentials) => axios.post('http://localhost:8080/api/auth/signin',credentials).then(res=>res.data.user)
}
}
The post request works on the server, but it gets stuck when I want to print.By stuck I mean when I press the login button nothing happens.
How can I print into the console res
?