Gianluca Ghettini Gianluca Ghettini - 1 year ago 95
Javascript Question

$Http.get(), how to deal with 404 response from WebAPI

On my web application I perform a

command to a remote HTTP WebAPI service

$http.get(url).then(function(data) { do_something(); });

everything works fine when the WebAPI returns some data, however the function doesn't seem to trigger when the WebAPI return a 404 error (no data to display).
How can I set a callback for it?

Answer Source
$http.get(url).then(function(data) {
}, function(err) {
  // your error function
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download