vue-resource
vue-resource copied to clipboard
handling in case of status code 204
Reproduction Link
await Post('my method name', JSON.stringify(my param)) .then(response => { console.log('response: ', response) if (Helper.IsValid(response, true)) { // code need to fire } }, response => { console.log('error response: ', response) })
Steps to reproduce
Chrome 57 / Windows 10 Pro
What is Expected?
In case of http return code 204 it should fire success handler of vue-resource.
What is actually happening?
In case of http return code 204 it should fire success handler but it's firing error handler of vue-resource..
couldn't you just check it with response.ok?
I'm also having trouble with the 201 status code being rejected. This is particularly difficult to handle when using a try catch statement. Anybody know why it would be rejected?
try {
this.hasPendingRequest();
const request = await this.$http.post(uri, data);
// handle good response
} catch (e) {
// handle bad response - 201 responses are also caught
} finally {
this.clearPendingRequest();
}
Hi @ivanwitzke , no matter it always goes to error section so you can not check it with "response.ok", for the time being i have changed it with "axios" plugin.
@KyleNeedham not sure if 201 is the root cause of the rejection.
Made a small example which seems to work fine.
https://jsfiddle.net/cv9xon73/
Hi @herrmannplatz ,
Service in the jsfiddle returning 403

Not sure why you get a 403. You might wanna check the error message in detail.
May be issue when using with vue application :)
@herrmannplatz You're right I just updated the endpoint to use a 201 again and it works fine. Must have been something else causing the error, also tried a 204 and that worked as well.