As the way of injecting API and call API by nuxt alias like this post NuxtJS - manage several axios instances
It is working well with vue file or middleware.
But since I create new folder in src is service for managing API, I can't call alias of API anymore.
-src
-plugins
-api.js
-services
-user.js
in file user.js, I use alias to call API but it does not work ($nuxt.$api)
user.js
export default {
async getUser(payload) {
return await $nuxt.$api.get('/user/', {
headers: {
Authorization: `Bearer ${payload}`
}
})
}
}
Any suggestion for my issue. Thank for your help.