pilwon / node-google-finance

Google Finance client library for Node.js.
207 stars 46 forks source link

Breaks when symbol doesn't exist #6

Open Stono opened 8 years ago

Stono commented 8 years ago

[ 'LON:VM', 'LON:BARC', 'LON:IDONTEXIST' ]

Unhandled rejection StatusCodeError: 400 - "<!DOCTYPE html><meta name=viewport content=\"initial-scale=1, minimum-scale=1, width=device-width\">Error 400 (Not Found)!!1<div id=\"af-error-container\">

400. That’s an error.

The requested URL was not found on this server. That’s all we know.

" at new StatusCodeError (/Users/kstoney/Development/stono/stocknet/sn.crawl.news/node_modules/request-promise-core/lib/errors.js:32:15) at Request.plumbing.callback (/Users/kstoney/Development/stono/stocknet/sn.crawl.news/node_modules/request-promise-core/lib/plumbing.js:104:33) at Request.RP$callback as _callback at Request.self.callback (/Users/kstoney/Development/stono/stocknet/sn.crawl.news/node_modules/request/request.js:187:22) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request. (/Users/kstoney/Development/stono/stocknet/sn.crawl.news/node_modules/request/request.js:1044:10) at emitOne (events.js:96:13) at Request.emit (events.js:188:7) at IncomingMessage. (/Users/kstoney/Development/stono/stocknet/sn.crawl.news/node_modules/request/request.js:965:12) at emitNone (events.js:91:20) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:934:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

thstarshine commented 7 years ago

Use request instead of request-promise at line 29 in lib/utils.js temprorarily solved this. btw pipe streaming is discouraged when using request-promise, maybe the downloadRSS function could be written in another way?

var requestCb = require('request')

var req = requestCb(_.extend({ uri: uri, qs: qs }, optionalHttpRequestOptions));