Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var brokenJson = function (url) {
- var responseCopy;
- return fetch(url)
- .then(function (response) {
- responseCopy = response.clone();
- return response.json();
- }).catch(function (err) {
- if (err instanceof SyntaxError) {
- return responseCopy.text()
- .then(function(text) {
- console.error(text);
- throw err;
- });
- }
- else {
- throw err;
- }
- }).then(function (json) {
- // do things
- });
- };
Add Comment
Please, Sign In to add comment