ggrossetie / unxhr

Synchronous and asynchronous XMLHttpRequest for Node
MIT License
0 stars 3 forks source link

resolves #30 set empty status text #31

Closed ggrossetie closed 3 years ago

ggrossetie commented 3 years ago

resolves #30

ggrossetie commented 3 years ago

Actually, both response and responseText are empty when an error occurred in asynchronous mode...

ggrossetie commented 3 years ago

Since we are not running in the browser, if we return an empty response and responseText the caller won't know why the request failed. I think it's a fair trade-off to set the stringify error in responseText. Alternatively, we could add a non-standard field with the error. For instance, onerror is called with a ProgressEvent. We could add an error field on this object to pass the error.

ggrossetie commented 3 years ago

I've decided to pass the error as a parameter of the onerror callback function, see #34.