Last active
January 6, 2017 00:24
-
-
Save blittle/f896759f124309952378244a632ab57e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {catchAsyncStacktrace} from 'auto-trace'; | |
function getPost(post) { | |
return fetch(`https://jsonplaceholder.typicode.com/posts/${post.id}`) | |
.then(resp => { | |
if (resp.ok) return resp.json(); | |
else throw `Error retrieving post with id: ${post.id}`; | |
}) | |
} | |
function first() { | |
getPost({id: 'no existy'}) | |
.then(data => console.log(data)) | |
.catch(catchAsyncStacktrace()); | |
} | |
first(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment