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

Bug when parsing JSON in superagent/lib/node/parsers/json.js #1448

Closed
DaggieBlanqx opened this issue Dec 24, 2018 · 1 comment
Closed

Bug when parsing JSON in superagent/lib/node/parsers/json.js #1448

DaggieBlanqx opened this issue Dec 24, 2018 · 1 comment

Comments

@DaggieBlanqx
Copy link

I am using a WordPress API module in NodeJS ( https://github.com/WP-API/node-wpapi )
When I make API requests ; it gets the json data , but causes an error .
When I open the stacktrace :

{ SyntaxError: Unexpected token  in JSON at position 0 at JSON.parse (<anonymous>) at IncomingMessage.res.on (C:\cde\fn\notification-stream\node_modules\superagent\lib\node\parsers\json.js:11:35) at IncomingMessage.emit (events.js:187:15) at endReadableNT (_stream_readable.js:1092:12) at process._tickCallback (internal/process/next_tick.js:63:19)

When I examine the file superagent/lib/node/parsers/json.js , I found a bug in how it parses JSON .

@kornelski
Copy link
Contributor

SyntaxError: Unexpected token  in JSON

This is not a bug. It means the server has sent some garbage instead or in addition to the JSON. It may also be caused by use of non-UTF-8 encoding.

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

No branches or pull requests

2 participants