Advertisement
Guest User

Untitled

a guest
Mar 7th, 2014
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. try {
  2.     var json = JSON.parse(yield interwebs.getJSON());
  3.     response.send(json.success);
  4. }
  5. catch (e) {
  6.     if (e instanceof SyntaxError) {
  7.         response.send("Invalid JSON!");
  8.     }
  9.     else {
  10.         throw e;
  11.     }
  12. }
  13.  
  14.  
  15. interwebs.getJSON()
  16.     .then(JSON.parse)
  17.     .then(json => response.send(json.success)
  18.     .catch(SyntaxError, e => response.send("Invalid JSON!"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement