reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

Fail response is undefined in 400 error

Open cruzlutor opened this issue 9 years ago • 2 comments

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?

cruzlutor avatar Jan 14 '16 06:01 cruzlutor

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);
});

meumanaresh avatar Feb 10 '16 03:02 meumanaresh

Same here +1

cristian-eriomenco avatar Sep 12 '16 10:09 cristian-eriomenco