There is a service that makes a request through $http , in the processing of a request (no matter resolve or reject ), I return some data through return , as a result, the service returns a promise , like (let's say in the controller where I called this service) check on the request was resolve or reject ?

Service example:

 return $http(option) .then(onResolve,onReject); 

An example of a service call:

 reguestService({ url: `someUrl`, method: 'get', }).then(function (response) { // Как тут узнать был ли запрос успешным или нет ? }); 
  • You yourself wrote: return $http(option) .then(onResolve,onReject); - Grundy

1 answer 1

You should have two functions in then . The first - the request was successful, the second - with an error.

 return $http.get(options) .then((response) => { console.log(response); return response; }, (error) => { console.error(error); return error; })