FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Capture JSON parsing errors in Promise by sunsean · Pull Request #112 · developit/unfetch · GitHub

Repository navigation

Capture JSON parsing errors in Promise - #112

Merged
developit merged 2 commits into
developit:masterfrom
sunsean:patch-1
Feb 19, 2020
Merged

developit merged 2 commits into
developit:masterfrom
sunsean:patch-1

Conversation

sunsean commented Mar 26, 2019

Copy link
Copy Markdown
Contributor

Currently invalid JSON in the response throws immediately instead of asynchronously.

iiroj left a comment •
edited
Loading

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We were also hit by this problem, and the change here certainly fixes it:

// Promise.resolve(JSON.parse(undefined)).then(() => console.log('success')).catch(() => console.log('fail')) 
SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
// Promise.resolve(undefined).then(JSON.parse).then(() => console.log('success')).catch(() => console.log('fail'))  
fail

pladaria left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

lgtm

developit left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

So sorry for sleeping on this PR!

developit merged commit ce5f373 into developit:master Feb 19, 2020
developit added a commit to kalisjoshua/unfetch that referenced this pull request Feb 19, 2020

Copy link
Copy Markdown
Owner

Released in 4.2.0. Sorry for the super long wait!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL