Intro
We all know that NuxtJS is an awesome framework. Unlike Angular which has a well structured folder for services, nuxt doesn't. But...
For further actions, you may consider blocking this person and/or reporting abuse
how to use it with Interceptors axios for refresh token when "token is invalid"? And save token, refresh token to cookies?
You can use interceptor and in onResponse you can check if your token is valid or not.
yes. when refresh token success but should I save token to vuex or cookies? thanks.
The simplest way is using localstorage to save your token.
But localStorage is client-side. How can i save it from server nuxtjs?
You can use this lib and use cookie for saving the info within nuxt server
can you give an example using lib or project using lib? tks you
You can see this doc
Hello guys, I have a question. This structure works also with typescript? Or it is necessary to do some modification?
Yes, this works with typescript
I use openapi-client-axios +
openapi.json
(i.e. Swagger) + TypeScript (optional).But I don't know how to inject to
$axios
.You can use nuxtjs/axios module and follow the installation intruction
It’s a great best practices that i apply on my project but i precise a prefix due to multiple services. Nice sharing 👍
Thank you
Another negative is that this gets pretty overcrowded
It'd be better if you could do this.$services.user.getUsers()
nice post! can you add an example of how you ll test this service using vue-test-utils?
I like the pattern. What is your approach when runtimeconfig/environment variables is needed? I'm having a problem how composables are not available outside script setup. My bad it's for nuxt 3