I want to make simple get request to my API deployed to Heroku. Here is how:
axios.get(my_url_here).then(res => this.topics = res.data).catch(e => {
print(JSON.stringify(e));
});
But, only catch works and it prints following:
{"message":"Network Error","name":"Error","stack":"Error: Network Error\n at createError (webpack-internal:///./node_modules/axios/lib/core/createError.js:16:15)\n at XMLHttpRequest.handleError (webpack-internal:///./node_modules/axios/lib/adapters/xhr.js:83:14)","config":{"url":"my_url_here","method":"get","headers":{"Accept":"application/json, text/plain, */*"},"transformRequest":[null],"transformResponse":[null],"timeout":0,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1}}
That error does not say anything. I couldn't find good materials about it, but some of them tells that it is a problem related to cors. I don't have any code related to Allow-origin
stuff on my API, but how the web browser successfully makes requests? And why axios fails and cannot make that requests? I tried to use cors
library on my server-side but when I deployed code to Heroku, it just stopped working. What can be the reason for above error and how to solve it?