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.

Ability to access the json response in case of error

See original GitHub issue

The documentation mentions that error handling is done in the catch handler of the promise. This handler receives an instance of an error object. But there’s no way to access the json that came in the error response body. At least there’s no documented way that I could find, and I tried checking if the catch handler received a second argument, or if the error object contains this somehow, but I couldn’t find it.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
alexlafrosciacommented, Oct 4, 2016

Sure is!

This is the only difference between request and raw, all the internals are the same. Sorry that the docs aren’t clear that it’s a method as well.

If you’re good with using raw then I’m going to close this. LMK if that doesn’t fix things for you.

0reactions
gnapsecommented, Oct 3, 2016

I read about the .raw method in the README, did not know about it before. Is this accessible as a method of the service object? Because I have no objection to use it like this:

this.get('ajax').raw(url, options)
  .then(...)
  .catch(...);

Does it still preserve any headers or customizations I made on the ajax service (namespace, headers, etc.)? If that’s so, then this case is mute. The thing is, in the README it does not appear this is the case. They mention importing it as some lower level API that does not use the service object at all, but rather the service object uses it.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix the Invalid JSON Response Error in WordPress
The response is not a valid JSON response," it will typically appear when you're working on content in the WordPress Block Editor. In...
Read more >
Error while parsing JSON Response in REST API Post call
I switched to returning a JSON String and then Deserialize the JSON String, it still raises an error "Failed to parse response of...
Read more >
Returning error JSON response in case of CustomException ...
As of now i am getting the proper json response as per bean EmployeeResponseData if the input empId is a match. But i...
Read more >
How to Fix “The Response Is Not a Valid JSON ... - iThemes
This guide explains how the Gutenberg editor works with REST API and how to fix "The response is not a valid JSON response"...
Read more >
Python Parse JSON response using requests library - PYnative
You can get a 204 error In case the JSON decoding fails. The response.json() raises an exception in the following scenario.
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