reqwest
reqwest copied to clipboard
Fail response is undefined in 400 error
I'm trying to get the server response in 400 status code request, but the second variable is undefined
reqwest({
url: 'exampleurl',
method: 'post',
data: {}
})
.then((resp) => {
...
})
.fail((err, resp) => {
console.log(err, resp)
})
the output console is
XMLHttpRequest {}, undefined
While the server response is a json object, in fails function it's undefined
It's a bug?
I'm facing the same issue. Any inputs on this is appreciated.
<!doctype html>
<html>
<body>
<script src="node_modules/es6-promise/dist/es6-promise.js"></script>
<script src="node_modules/reqwest/reqwest.js"></script>
<script src="src/js/test.js"></script>
</body>
</html>
reqwest({
url: "www.google.com"
, type: 'json'
, method: 'post'
, contentType: 'application/json'
, headers: {
'X-My-Custom-Header': 'SomethingImportant'
}
}).then((res)=> {
alert(res);
}, (err)=> {
alert(err);
});
Same here +1