0

In my Angular2 App when a Promise call errors out, how can I get the original request url and body content ? I want to get more details like what was the Url called and what was the body content. I am not seeing it in the "error" parameter.

private handleError(error: any): Promise<any> {
    if (error.status == 0) {
        alert("Unable to reach the remote server.");
    }

    return Promise.reject(error.message || error);
}

Please advise.

Adam
  • 1,221
  • 4
  • 13
  • 27

1 Answers1

0

For local purposes you could look into the network tab of your Developer tools.

AFAIK there is no way to get this information from the error object. But you could wrap your network requests and extend the error object with your general params.

If you really want the xhr request object you should extend the Http class and register it like here:

What is httpinterceptor equivalent in angular2?

Community
  • 1
  • 1
Harper04
  • 355
  • 2
  • 10