Axios usage
In the first example we show how to use the env property in our nuxt.config.js
file to add the URL of our API so that we can then easily make calls to it without having to use the URL on our page
In this example:
nuxt.config.js
contains :
-
the
publicRuntimeConfig
property to add the URL of our API. -
the
modules
property to register our@nuxtjs/axios
module.
pages/index.vue
- uses $axios
to fetch our data and $config
to retrieve our API URL.
Learn more about the axios module .
Learn more in the Directory Structure book in the nuxt-config chapter.
Loading Sandbox...
Editer cette page sur GitHub
Mise à jour le Mon, July 12, 2021