Created
October 4, 2019 14:41
-
-
Save nolimits4web/e0c8765d663e66a20ed5d5731fea814d to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // 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