mirror of
https://github.com/nuxt/nuxt.git
synced 2025-01-30 23:32:38 +00:00
Add post link for async/await
This commit is contained in:
parent
aa1df39142
commit
f4ca19ee73
@ -9,7 +9,7 @@
|
|||||||
The `data` method receives the context as the first argument, you can use it to fetch some data and return the component data. To make the data method asynchronous, Nuxt.js offers you different ways, choose the one you're the most familiar with:
|
The `data` method receives the context as the first argument, you can use it to fetch some data and return the component data. To make the data method asynchronous, Nuxt.js offers you different ways, choose the one you're the most familiar with:
|
||||||
|
|
||||||
1. returning a `Promise`, Nuxt.js will wait for the promise to be resolved before rendering the Component
|
1. returning a `Promise`, Nuxt.js will wait for the promise to be resolved before rendering the Component
|
||||||
2. Using the [async/await proposal](https://github.com/lukehoban/ecmascript-asyncawait)
|
2. Using the [async/await proposal](https://github.com/lukehoban/ecmascript-asyncawait) ([learn more about it]([learn more about it](https://zeit.co/blog/async-and-await))
|
||||||
3. Define a second argument which is a callback method to be called like this: `callback(err, data)`
|
3. Define a second argument which is a callback method to be called like this: `callback(err, data)`
|
||||||
|
|
||||||
Example with returning a `Promise`:
|
Example with returning a `Promise`:
|
||||||
|
Loading…
Reference in New Issue
Block a user