fetch Hook
In this example we use the fetch hook to fetch data from components and from pages
In this example:
pages/index.vue imports components/Mountains.vue which uses the fetch hook and the $http module to fetch our data at component level while pages/mountains/_slug fetches the data at page level and include:
-
$fetchState.pendingto show a loading text when the data is loading. -
$fetchState.errorto show an error message when we can't retrieve the data. -
$fetchto fetch the data again when clicked.
Learn more about the http module .
Learn more about the fetch hook in the Features book in the Data Fetching chapter.
Loading Sandbox...
Editer cette page sur GitHub
Mise à jour le Mon, July 12, 2021