question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid JSON response body

See original GitHub issue

Describe the bug When fetching any data using your player endpoint, I get this error when trying to parse the response.

Profile/Location https://sky.shiiyu.moe/api/v2/profile/sirarchibald97

Additional Info I can send requests from my browser perfectly fine, it’s just parsing the response in Node which returns the error. I am using the npm package Node-Fetch.

Expected behavior I should be able to parse the data from JSON into a JavaScript object, as I can with all other APIs that return JSON.

Screenshots

UnhandledPromiseRejectionWarning: FetchError: invalid json response body at https://sky.shiiyu.moe/api/v2/profile/[19]%20SirArchibald97 reason: Unexpected token < in JSON at position 0
2021-01-03T16:06:09.291399+00:00 app[worker.1]:     at /app/node_modules/node-fetch/lib/index.js:272:32
2021-01-03T16:06:09.291400+00:00 app[worker.1]:     at processTicksAndRejections (internal/process/task_queues.js:97:5)
2021-01-03T16:06:09.291400+00:00 app[worker.1]:     at async Object.run (/app/methods/nick.js:35:32)
2021-01-03T16:06:09.291475+00:00 app[worker.1]: (node:4) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
2021-01-03T16:06:09.291581+00:00 app[worker.1]: (node:4) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Desktop (please complete the following information):

  • OS: macOS
  • Browser: Chrome
  • Version: n/a

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SomeRandom-WhoLikesCodecommented, Jan 4, 2021

It might be because the URL it’s pointing to in your error looks like: https://sky.shiiyu.moe/api/v2/profile/[19] SirArchibald97 and not https://sky.shiiyu.moe/api/v2/profile/SirArchibald97

0reactions
metalcupcake5commented, Jan 5, 2021

Glad it’s been resolved!

Read more comments on GitHub >

github_iconTop Results From Across the Web

invalid json response body error with Express node-fetch ...
Try res => console.log(res) in your first .then() block to see what the response is. Usually that error "Unexpected token < in JSON....
Read more >
invalid json response body at...reason: Unexpected token < in ...
This means that the fetch call did not receive JSON, but, most likely HTML. That also means that something is wrong in that...
Read more >
Npm Err Invalid Json Response Body Unexpected End of ...
Just run the following command, to clear you local npm cache folder. ... That kind of error, happened when your network is not...
Read more >
fetcherror { message: 'invalid json response body at reason
Generally this error means the response you got is not properly formatted JSON. You can inspect it by console.log() , and parsing the...
Read more >
How to Fix the Invalid JSON Error in WordPress? - YouTube
Have you ever tried to upload a file or modify a piece of content on your WordPress site and been greeted by a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found