Closed mylastore closed 4 years ago
Thank you
always welcome <3
export const ifetch = (url, { options = {}, accessToken = '' } = {}) =>
fetch(url, {
method: 'GET',
...options,
headers: {
'Content-Type': 'application/json',
'Accept-Language': 'en',
Authorization: `Bearer ${accessToken}`,
...options.headers
}
})
export const authService = {
fetchUser: async ({ cookies }) => {
const { accessToken } = cookies
if (!accessToken)
return {
data: undefined,
ok: true,
status: 200
}
const url = process.env.API_AUTH_USER
const response = await ifetch(url, { accessToken })
const data = await response.json()
return {
data,
ok: response.ok,
status: response.status
}
}
}
First of all thank you for sharing this awesome repo ;)
Sign-in endpoint returns token. How do I get the user data?