Ability to force JSON.parse of the response when content-type is not application/json
See original GitHub issueSuperagent should JSON.parse the response when a user sets that he expects a json via accept('json')
in the request, no matter what content-type was set in the response header.
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:7 (2 by maintainers)
Top Results From Across the Web
Ability to force JSON.parse of the response when content-type ...
Superagent should JSON.parse the response when a user sets that he expects a json via accept('json') in the request, no matter what ...
Read more >JSON.parse() does not work when content-type is set to ...
When you specify nothing for the dataType , and "json" for the Content-Type header, response is parsed as JSON (Javascript object literal).
Read more >Handle content types - Azure Logic Apps - Microsoft Learn
By default, you can parse JSON content without any casting. To parse a request that has a header with the "application/json" content type, ......
Read more >JSON requests and responses - Atlassian Developer
To make a request with JSON, the appropriate HTTP headers are: Copy. 1 2 Content-Type: application/json Accept: application/json ...
Read more >An Exploration of JSON Interoperability Vulnerabilities
In this research, I conducted a survey of 49 JSON parsers, cataloged their quirks, and present a variety of attack scenarios and Docker...
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
Try this:
Did anything happen regarding this issue? The workaround proposed by @teebot is not working, as in my case response.body contains an empty object {}.
The output is:
Result: {}
The problem is, that the server does not send a Content-Type header. But I think, that there should be an option to tell superagent to parse the response, no matter what the server sends.