Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- var json = JSON.parse(yield interwebs.getJSON());
- response.send(json.success);
- }
- catch (e) {
- if (e instanceof SyntaxError) {
- response.send("Invalid JSON!");
- }
- else {
- throw e;
- }
- }
- interwebs.getJSON()
- .then(JSON.parse)
- .then(json => response.send(json.success)
- .catch(SyntaxError, e => response.send("Invalid JSON!"));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement