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...
Edit this page on GitHub
Updated at Mon, Aug 19, 2024
Sébastien Chopin
Nazaré da Piedade
Nobu
川音리오
Maciek Palmowski
Nestor Vera
Daniel Roe
Yue Yang
Jeronimas
Clément Ollivier
Alexander Lichter
N3-rd
Adrien Zaganelli
Mag
Stefan Huber
Olga Bulat
Paiva
Florian Reuschel
Savas Vedova
HIJACK
Vinícius Alves
Kareem Dabbeet
Valentín Costa
Ryan Skinner
Alex Hirzel
Ajeet Chaulagain
René Eschke
Nico Devs
Muhammad
Naoki Hamada
Tom
Yann Aufray
Anthony Chu
Nuzhat Minhaz
Lucas Portet
Richard Schloss
Bobby
bpy
Antony Konstantinidis
Hibariya
Jose Seabra
Eze
Florian Lefebvre
Lucas Recoaro
Julien SEIXAS