Skip to content
This repository has been archived by the owner on Mar 17, 2024. It is now read-only.

cannot read property split of undefined #54

Closed
yawhide opened this issue Dec 2, 2016 · 4 comments
Closed

cannot read property split of undefined #54

yawhide opened this issue Dec 2, 2016 · 4 comments

Comments

@yawhide
Copy link

yawhide commented Dec 2, 2016

Hello,
getting this weird error.

D:\GitHub\work>node cron\scrape.js
Unhandled rejection TypeError: Cannot read property 'split' of undefined
    at D:\GitHub\work\node_modules\snoowrap\dist\request_handler.js:232:37
    at tryCatcher (D:\GitHub\work\node_modules\bluebird\js\release\util.js:16:23)
    at Promise._settlePromiseFromHandler (D:\GitHub\work\node_modules\bluebird\js\release\promise.js:510:31)
    at Promise._settlePromise (D:\GitHub\work\node_modules\bluebird\js\release\promise.js:567:18)
    at Promise._settlePromise0 (D:\GitHub\work\node_modules\bluebird\js\release\promise.js:612:10)
    at Promise._settlePromises (D:\GitHub\work\node_modules\bluebird\js\release\promise.js:691:18)
    at Async._drainQueue (D:\GitHub\work\node_modules\bluebird\js\release\async.js:138:16)
    at Async._drainQueues (D:\GitHub\work\node_modules\bluebird\js\release\async.js:148:10)
    at Immediate.Async.drainQueues (D:\GitHub\work\node_modules\bluebird\js\release\async.js:17:14)
    at runCallback (timers.js:649:20)
    at tryOnImmediate (timers.js:622:5)
    at processImmediate [as _immediateCallback] (timers.js:594:5)

Here is the code I am using:

const config = require('../config');
const snoowrap = require('snoowrap');
const subreddits = [
  'Laptop'
]
const r = new snoowrap(config.reddit);
r.getSubreddit(subreddits[0]).getNew({time: 'year'}).then(console.log);

pretty straight forward stuff.
any ideas why this is happening?

node v7.2.0 win 10m latest snoowrap lib

@yawhide
Copy link
Author

yawhide commented Dec 2, 2016

weird so I had my app as a "web app". change it to "script" and now it works. weird error still though.

@yawhide yawhide closed this as completed Dec 2, 2016
@not-an-aardvark
Copy link
Owner

Thanks, I'm glad you managed to figure it out.

For future reference, what was in your config file? (You can omit things like credentials, of course -- I'm just interested in what type of authentication you used that caused the confusing error.)

@yawhide
Copy link
Author

yawhide commented Dec 2, 2016

It was the fact that my Reddit application type was set to web app it I was using username/password combo.

@porteron
Copy link

I had the same error as above and changing the Reddit application type to script fixed the issue as well.
I was using nodeJS.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants