New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error response object is undefined #883
Comments
I have the same problem. Did something change? |
Hey had this happen to me, the issue is that the api on what a rejected promise returns has changed. Before you did something like this
but now you have to do something like this
I had bumped from something pre v0.10.0 to v0.16.1 |
I'm having the exact same issue and found this thread helpful: #383 Likely has to do with a CORS header not being present for that response code. |
Thanks @tyleriguchi and @graysonlangford for the help. And yes the CORS header wasn't present for the response code. |
This is maybe related... It happens to me that on authenticated (value is set in // axios-config.js
import Vue from 'vue'
import axios from 'axios'
import store from '~/store'
import router from '~/router'
axios.interceptors.request.use(request => {
if (store.getters.authToken) {
request.headers.common['Authorization'] = `Bearer ${store.getters.authToken}`
}
request.data.locale = store.getters.locale // <- EXTRA DATA ATTACHED
return request
}) // store/auth.js
// . . .
async fetchUser ({ commit }) {
try {
const { data } = await axios.get('/user/current') // <-- I GET THE ERROR HERE
commit(types.FETCH_USER_SUCCESS, { user: data })
} catch (e) {
console.error(e)
commit(types.FETCH_USER_FAILURE)
}
}, For non successful login it works fine all. I get this error only there (when I try to get the current user). And is gone if I remove the extra data from the interceptors. So, my problem is then the I ended up to use cookies to get the |
|
For me the thrown error actually |
In my case, I imported axios on a document and created a baseUrl, so I exported it, but when I import that document in another one, it says that can not read property create of undefined |
#### Summary
Hello,
I am making an API HTTP request using axios but i don't get an error object in response. The response for the error comes as undefined and I only get the instance of an error object if I console.log(error).
I have followed the same pattern for error handling which is in the documentation.
Here is the screenshot of the console showing only the instance of error when I do console.log(error).
Here is another screenshot showing error.response as undefined.
I have 404 as status code also the response body is in the image below.
The text was updated successfully, but these errors were encountered: