Skip to content

Instantly share code, notes, and snippets.

@nolimits4web
Created October 4, 2019 14:41
Show Gist options
  • Select an option

  • Save nolimits4web/e0c8765d663e66a20ed5d5731fea814d to your computer and use it in GitHub Desktop.

Select an option

Save nolimits4web/e0c8765d663e66a20ed5d5731fea814d to your computer and use it in GitHub Desktop.
// return promise
{
//...
data() {
return new Promise((resolve) => {
fetch('some/path')
.then(res => res.json())
.then(user => resolve({ user }))
});
},
}
// or same with async-await
{
//...
async data() {
const user = await fetch('some/path').then(res => res.json());
return {
user,
};
},
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment