Page traduite Le contenu de cette page peut être déprécié.
Utilisation d'Axios
Dans le premier exemple, nous montrons comment utiliser la propriété env dans notre fichier nuxt.config.js
pour ajouter l'URL de notre API afin que nous puissions ensuite facilement y faire des appels sans avoir à utiliser l'URL de notre page.
Dans cet exemple :
nuxt.config.js
contient :
-
la propriété
publicRuntimeConfig
pour ajouter l'URL de notre API. -
la propriété
modules
pour enregistrer notre module@nuxtjs/axios
.
pages/index.vue
- utilise $axios
pour récupérer nos données et $config
pour récupérer l'URL de notre API.
En savoir plus à propos du module axios .
En savoir plus dans le chapitre nuxt-config .
Loading Sandbox...
Editer cette page sur GitHub
Mise à jour le lun. 19 août 2024












































