Invalid JSON response body
See original GitHub issueDescribe 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:
- Created 3 years ago
- Comments:9 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
Glad it’s been resolved!