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.

res not returned when superagent fails JSON parsing

See original GitHub issue

In the JSON parser:

  res.on('end', function(){
    try {
      fn(null, JSON.parse(res.text));
    } catch (err) {
      fn(err);
    }
  });

The res object is not returned on a failed parse - I cannot inspect headers or anything else on the res that might be of interest or can give me a way to handle failed parsing.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
kornelskicommented, Dec 16, 2015

Unparseable input is now returned as a property of the error.

0reactions
castrolemcommented, Dec 16, 2015

+1

Read more comments on GitHub >

github_iconTop Results From Across the Web

res not returned when superagent fails JSON parsing #487
This fails for me in 0.21.0. I only get back error object and a null res. Error message is "Parser is unable to...
Read more >
Superagent: Error: Parser is unable to parse the response
So to be clear, when uploading a single file, I get a nice JSON response, but when I upload multiple files, the response...
Read more >
How to use the superagent.parse function in ... - Snyk
To help you get started, we've selected a few superagent.parse examples, ... if (!text) return done(null, {result: []}); try { done(null, JSON.parse(text)); } ......
Read more >
superagent | Yarn - Package Manager
end(…) . Consider not using .end() at all, and migrating to promises by calling .then() instead. In Node, responses with unknown MIME type...
Read more >
Error: Parser is unable to parse the response-Reactjs
Coding example for the question Superagent: Error: Parser is unable to parse the response-Reactjs.
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