fetch Hook
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.pending
to show a loading text when the data is loading.$fetchState.error
to show an error message when we can't retrieve the data.$fetch
to 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 CodeSandbox...