Adnan Erlansyah
Adnan Erlansyah
NNuxt
Created by Adnan Erlansyah on 11/13/2024 in #❓・help
How to make software as a service in NuxtJS3?
How to make software as a service with NuxtJS3? What's the structure looks like if we want to make it?
10 replies
NNuxt
Created by Adnan Erlansyah on 11/12/2024 in #❓・help
The best practice for using typescript on NuxtJS3
How to make types for the response data that we get by using typescript on NuxtJS3.
5 replies
NNuxt
Created by Adnan Erlansyah on 11/12/2024 in #❓・help
Reusable methods that can be use in any pages
How to make reusable methods and that can be used in any pages. Please make it for the most best practice of it.
4 replies
NNuxt
Created by Adnan Erlansyah on 11/12/2024 in #❓・help
How to make state management in NuxtJS3
Hello everyone, can anyone help me out about how we can make state management by using pinia in the best way or practice?
10 replies
NNuxt
Created by Adnan Erlansyah on 11/11/2024 in #❓・help
How to handle infinite redirect in navigation guard?
Hello everyone, Can anyone help me out about the issue infinite redirect when we want to make middleware for the authentication user. So I want when the user has already logged in and then try to access login page again then they hasn't access to it. My code:
// @ts-nocheck
export default defineNuxtRouteMiddleware((to, from) => {
const { isAuthenticated } = useAuth();

// Check if the user is authenticated
if (!isAuthenticated()) {
return navigateTo('/auth/login')
} else {
return navigateTo('/homepage')
}
})
// @ts-nocheck
export default defineNuxtRouteMiddleware((to, from) => {
const { isAuthenticated } = useAuth();

// Check if the user is authenticated
if (!isAuthenticated()) {
return navigateTo('/auth/login')
} else {
return navigateTo('/homepage')
}
})
10 replies
NNuxt
Created by Adnan Erlansyah on 11/11/2024 in #❓・help
How to save the state of user's authentication
Hello everone, I want to ask about how to save the state of user and token in the browser to tracking it whether the user is still valid or not.
5 replies
NNuxt
Created by Adnan Erlansyah on 11/11/2024 in #❓・help
How to make middleware auth in nuxtjs3?
Hello everyone, can anyone help me again about how we can make the middleware for authentication user & role user in nuxtjs 3. My Response Data looking like this:
{
"status": true,
"message": "Login successful",
"data": {
"user": {
"id": 7,
"rememberToken": null,
"fullName": "User Example",
"email": "[email protected]",
"phone": null,
"province": null,
"city": null,
"address": null,
"gender": "l",
"roleId": 1,
"experience": null,
"rating": 0,
"photo": null,
"biography": null,
"status": 1,
"isVerified": 1,
"createdAt": "2024-10-30T07:43:48.000+00:00",
"updatedAt": "2024-10-30T07:43:48.000+00:00"
},
"token": {
"headers": {
"authorization": "Bearer oat_Mjk.aWo0Z3lxSEFXS0NUaGt5ejFhbVNwU2xhT3pMM3dRYUlXT29mMVFCRzEyMTcxMzI4MzM"
}
}
}
}
{
"status": true,
"message": "Login successful",
"data": {
"user": {
"id": 7,
"rememberToken": null,
"fullName": "User Example",
"email": "[email protected]",
"phone": null,
"province": null,
"city": null,
"address": null,
"gender": "l",
"roleId": 1,
"experience": null,
"rating": 0,
"photo": null,
"biography": null,
"status": 1,
"isVerified": 1,
"createdAt": "2024-10-30T07:43:48.000+00:00",
"updatedAt": "2024-10-30T07:43:48.000+00:00"
},
"token": {
"headers": {
"authorization": "Bearer oat_Mjk.aWo0Z3lxSEFXS0NUaGt5ejFhbVNwU2xhT3pMM3dRYUlXT29mMVFCRzEyMTcxMzI4MzM"
}
}
}
}
9 replies
NNuxt
Created by Adnan Erlansyah on 11/11/2024 in #❓・help
How to custom baseURL of fetching api as our own?
Hello everyone, can anyone help me about how we can fetching the api without put baseURL everytime we want to get the data. So I don't want to make like this
const { data: products, pending, refresh } = useFetch('/products', {
baseURL: config.public.apiBase,
params: {
search: searchVal.value,
sort: sortVal.value,
filter: filterVal.value,
},
immediate: true,
// lazy: false
})
const { data: products, pending, refresh } = useFetch('/products', {
baseURL: config.public.apiBase,
params: {
search: searchVal.value,
sort: sortVal.value,
filter: filterVal.value,
},
immediate: true,
// lazy: false
})
5 replies