ToothlessGear / node-gcm

A NodeJS wrapper library port to send data to Android devices via Google Cloud Messaging
https://github.com/ToothlessGear/node-gcm
Other
1.3k stars 208 forks source link

Handle non-HTTP errors #375

Closed silentjohnny closed 8 months ago

silentjohnny commented 9 months ago

When a non-HTTP error occurs, e.g., a timeout, the err instance does not contain a response.

This means that this:

const { response: res } = err;

if (res.status === 401) {

will fail because of res being undefined

eladnava commented 8 months ago

Thanks for catching this and submitting a PR @silentjohnny!

Merged and published to npm as 1.1.1. 🎉