Skip to content

Instantly share code, notes, and snippets.

@blittle
Last active January 6, 2017 00:24
Show Gist options
  • Save blittle/f896759f124309952378244a632ab57e to your computer and use it in GitHub Desktop.
Save blittle/f896759f124309952378244a632ab57e to your computer and use it in GitHub Desktop.
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