Guest User

Untitled

a guest
Nov 19th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. var brokenJson = function (url) {
  2. var responseCopy;
  3. return fetch(url)
  4. .then(function (response) {
  5. responseCopy = response.clone();
  6. return response.json();
  7. }).catch(function (err) {
  8. if (err instanceof SyntaxError) {
  9. return responseCopy.text()
  10. .then(function(text) {
  11. console.error(text);
  12. throw err;
  13. });
  14. }
  15. else {
  16. throw err;
  17. }
  18. }).then(function (json) {
  19. // do things
  20. });
  21. };
Add Comment
Please, Sign In to add comment