FetchError: invalid-json
See original GitHub issueI have a Discord Bot and on my Windows 10 64x PC it works fine, but on my VM Debian 10 Server i got the following error and I dont know why. If i run on my computer(Windows 10 VSC Debugger) the
but on my VM (Debian 10)
tbh i dont know why it works on my pc fine and on my server i got the error with the same packages and versions
Error:
/home/lennart/Discordbots/v2/node_modules/node-fetch/lib/index.js:272
return Body.Promise.reject(new FetchError(`invalid json response body at ${_this2.url} reason: ${err.message}`, 'invalid-json'));
^
FetchError: invalid json response body at https://karmatop.de/addon/pxl-api.php?name=L3nnart_ reason: Unexpected token < in JSON at position 0
at /home/lennart/Discordbots/v2/node_modules/node-fetch/lib/index.js:272:32
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5) {
type: 'invalid-json'
}
Example Code
const url = `https://karmatop.de/addon/pxl-api.php?name=` + spieler; //spieler is a variable/argument from the discord bot, for example "L3nnart_"
fetch(url, {
method: "GET",
headers: {
Accept: "application/json",
},
})
Your Environment
software | version |
---|---|
node-fetch | 2.6.1 |
node | 16.8 |
npm | 7.21.0 |
Operating System | Deabian/Windows |
Issue Analytics
- State:
- Created 2 years ago
- Comments:6
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 ...
Is there any solution for this error? FetchError: invalid json response body at http://mydomain.com/graphql reason: Unexpected token < in JSON ...
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: invalid response body while trying to fetch - You.com
The error is triggered because you are getting a HTML response instead of JSON. If you make the request from the browser you...
Read more >Connectivity | EOSIO Developer Docs
invalid json response body ... This typically means you have connected to a computer that is not running EOSIO software. For example, if...
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 FreeTop 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
Top GitHub Comments
Bumping the wrong issue… should maybe bump #541 with a potential fix: https://github.com/node-fetch/node-fetch/pull/1482
My nodejs app recently crashed due to node-fetch, The exception is the same as you