Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected token o in JSON at position 0 #69

Closed
bevbomb opened this issue Aug 17, 2017 · 2 comments · Fixed by #70
Closed

Unexpected token o in JSON at position 0 #69

bevbomb opened this issue Aug 17, 2017 · 2 comments · Fixed by #70
Assignees

Comments

@bevbomb
Copy link

bevbomb commented Aug 17, 2017

I'm receiving the following error after trying to use the client to get all items. Here is the following error stack trace.

SyntaxError: Unexpected token o in JSON at position 0
    at Object.parse (native)
    at self.oa.get.stream (/user_code/node_modules/xero-node/lib/application.js:303:33)
    at passBackControl (/user_code/node_modules/xero-node/lib/oauth/oauth.js:406:25)
    at IncomingMessage.<anonymous> (/user_code/node_modules/xero-node/lib/oauth/oauth.js:422:17)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickDomainCallback (internal/process/next_tick.js:128:9)

data = JSON.parse(data)

@jordanwalsh23
Copy link
Contributor

Yes, this is because the data coming back for oauth errors is not valid JSON.

This is going to be because your oauth token is either invalid, expired, or the signature validation has failed.

To debug I suggest you sign up for a runscope account and place the runscope bucket ID in your config.json. This will allow you to log the requests and see the exact content so you can resolve your issue.

In the mean time I'll figure out a way to convert the non-json to json for responding.

@bevbomb
Copy link
Author

bevbomb commented Aug 17, 2017

Thank you, I was able to find and fix my issue.
I figured that the returned results would have been an error of some description.

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

Successfully merging a pull request may close this issue.

2 participants