t3chnoboy / amazon-product-api

:credit_card: Amazon Product Advertising API client
366 stars 104 forks source link

response underfined #12

Closed henrikekblad closed 9 years ago

henrikekblad commented 9 years ago

Would be good to add a !response check on the following line. https://github.com/t3chnoboy/amazon-product-api/blob/master/lib/index.js#L19

If internet connection is down this causes an exception:

TypeError: Cannot read property 'statusCode' of undefined
    at Request._callback (/Users/hek/git/nodebb-plugin-affiliate/node_modules/amazon-product-api/lib/index.js:19:21)
    at self.callback (/Users/hek/git/nodebb-plugin-affiliate/node_modules/request/request.js:368:22)
    at Request.emit (events.js:107:17)
    at Request.onRequestError (/Users/hek/git/nodebb-plugin-affiliate/node_modules/request/request.js:1025:8)
    at ClientRequest.emit (events.js:107:17)
    at Socket.socketErrorListener (_http_client.js:271:9)
    at Socket.emit (events.js:107:17)
    at net.js:940:16
    at process._tickDomainCallback (node.js:381:11)
t3chnoboy commented 9 years ago

Yeah, that would be nice! I see you have already forked the project and made necessary changes. Would you mind making a PR?