I've got an app using DJRF for the backend and Vue for the front end. I'm also using Djoser for authentication, which is the endpoint I'm trying to reach out to. I've got Vue reaching out to an API for the data and I'm using Postman to test, which works out perfectly fine. However, I'm trying to make a POST request with Axios on the frontend and I keep getting this error
Uncaught (in promise) TypeError: Cannot read property 'error' of undefined
logIn: () => {
axios
.post("http://127.0.0.1:8000/auth/token/login/", {
email: "test2@test.com",
password: "password"
})
.then(response => {
this.authtoken = response.authtoken;
})
.catch(error => {
this.error = error;
});
}
I make this request with Postman and don't have issues so I figure it's not a problem with anything on the backend. I've also tried just using the url extension without the IP address and also using 'localhost'.
Lastly, looking at my terminal, when I make the request it returns a status code of 200. Something with how I'm setting up this POST request with Axios?