I'm currently working with a VUEJS / VUEJS Resources code snippet that retrieves data from an API service.
fetchData: function(name){
var self = this;
self.$http.get('http://www.apiservice.com/', {
params: {
city: name
},
}).then((response) => {
// success callback
toastr.success('Success!');
console.debug(response);
}, (response) => {
// error
toastr.error('Something went wrong!')
});
}
However, the API always returns a 200 OK response, making it hard to determine when to display an error using toastr.error
.
In case of a false response, it will look like this:
{Response: "False", Error: "City not found!"}
.
Here's my question
Is there a way to identify the false
value in the response of a 200 OK return and trigger an error message?