rchipka / node-osmosis

Web scraper for NodeJS
4.12k stars 245 forks source link

header and headers options are not working #197

Open ghost opened 6 years ago

ghost commented 6 years ago
osmosis.header('Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8')

gives error

var opts = this.getOpts(), headers;
                    ^

TypeError: this.getOpts is not a function
    at module.exports (F:\node\node_modules\osmosis\lib\commands\header.js:14:21)
    at F:\node\node_modules\osmosis\lib\Command.js:468:22
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
samogot commented 6 years ago

You should use .config or .header after .get. Runtime commands are applied to previous context command, not to next one. It's not so obvious, but it works)