Closed fantapop closed 6 years ago
Checkout the request library, you can see how to handle the http response there. Getting an error or promise rejection usually means that the request
was not made due to an error (usually network related.), which means if you are not getting an error, there will always be a response
and body
. At this point, the One Signal API has already sent you a response, so you need to check the status code to understand if the request was successful.
It would be great if the fact that there was an http request happening under the covers was abstracted from the user.
Looking at the code, it looks like on error in basic request you call the callback with the http response but you don't reject the promise with it. This means I need to pass a callback in order to get access to this object. I'm wondering if httpResponse will ever be defined in case of error?
Also, based on the code it looks like I need to inspect the status code to determine the request was successful. Is this true? I don't see anywhere in the request module that it throws on non-200.
Thanks for your work on this.