const { user, isLoading, isAuthenticated, logout, getToken } = useKindeAuth()
const router = useRouter()
useEffect(() => {
if (!isLoading && !isAuthenticated) {
router.push('/auth/signin')
}
}, [isAuthenticated, isLoading, router])
const fetchData = async () => {
try {
const accessToken = await getToken()
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/emails`, {
headers: {
Authorization: `Bearer ${accessToken}`
}
})
const result = await response.json()
} catch (err) { xx } finally { xx }
}
const { user, isLoading, isAuthenticated, logout, getToken } = useKindeAuth()
const router = useRouter()
useEffect(() => {
if (!isLoading && !isAuthenticated) {
router.push('/auth/signin')
}
}, [isAuthenticated, isLoading, router])
const fetchData = async () => {
try {
const accessToken = await getToken()
const response = await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/emails`, {
headers: {
Authorization: `Bearer ${accessToken}`
}
})
const result = await response.json()
} catch (err) { xx } finally { xx }
}