Guest User

Untitled

a guest
Mar 7th, 2014
154
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!"));
RAW Paste Data