[Vuejs]-How to access $axios in composition API without using useContext

0👍

Nuxt 3 officially recommends using $fetch for making http request

Note that $fetch is the preferred way to make HTTP calls in Nuxt 3 instead of @nuxt/http and @nuxtjs/axios that are made for Nuxt 2.
https://nuxt.com/docs/api/utils/dollarfetch

However if you want to set it up for example to add headers, you can create a composable and work with it throughout the nuxt app

import axios from "axios"; 
export const $axios = axios.create({ 
   baseURL: BASE_URL, 
   headers: { 
     ...headers
   }, 
});

Leave a comment