can't get errors after a post request
See original GitHub issueI’dont know if this (#41) is fixed or not but i’ve this situation:
login(email = '', password = '') {
let request = axios({
url: api.session,
method: 'post',
data: {
user: {
email: email,
password: password
}
},
headers: {
'Content-Type': 'application/json',
'X-Requested-With': 'XMLHttpRequest'
}
})
.catch(reason => {
console.log(reason)
return reason;
})
.then(function(response){
console.log(response)
return response;
})
}
but what i see is that the response arrives only if the status is 200 otherwise it doesn’t enter in catch
and even in then
it just stops.
this is what i see when i try to enter wrong credentials in my form:
XMLHttpRequest cannot load http://url/session. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8088' is therefore not allowed access. The response had HTTP status code 401.
EDIT:
this is my setup:
axios.defaults.headers.post['Content-Type'] = 'application/json';
axios.defaults.headers.post['Accept'] = 'application/json';
axios.defaults.transformRequest = [(data) => JSON.stringify(data.data)];
Issue Analytics
- State:
- Created 8 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
Cannot GET on POST request - Stack Overflow
You're seeing that error because you must be trying to access the url via the web browser, which sends the GET request.
Read more >How to Fix Request Method 'POST' Not Supported - Hyperping
The Request Method' POST' Not Supported' is an HTTP response status. The error prompt shows that a request to access your website has...
Read more >List of HTTP status codes - Wikipedia
This is a list of Hypertext Transfer Protocol (HTTP) response status codes. Status codes are issued by a server in response to a...
Read more >Twitter API Response Codes & Error Support
Different error codes indicate different reasons for an error. The Twitter API attempts to return appropriate HTTP status codes for every request.
Read more >Error Messages | Maps JavaScript API - Google Developers
An error has occurred that doesn't fit into the other categories on this page. This could be caused by a temporary problem. Please...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
It’s strange because i get this error only if user and pass are wrong otherwise if i type correct login data the promise works well because the server return 200
Hi I have the same problem. I’ve just switched from jquery ajax to axios, but I can’t make it works.
$.post(url, params, function() {…}); -> works great
axios({ method: ‘post’, url: url, data: params, headers: { ‘Content-Type’: ‘application/json’ } });
doesnt work. I get allways ‘method non allowed’ error, and I dont know why, but it sent as request method “OPTIONS” not “POST”. and I cant see my parameters either. Am I missing something? any solution? it needs to be POST and ‘Content-Type’: ‘application/json’.
thanks