feat: implement HttpServer for API requests and add getUser function for user profile retrieval

This commit is contained in:
Ardeman
2025-02-28 23:56:47 +08:00
parent 9bc7fbb902
commit 0577975846
5 changed files with 42 additions and 19 deletions
+5
View File
@@ -3,6 +3,7 @@ import { data } from 'react-router'
import { getValidatedFormData } from 'remix-hook-form'
import { XiorError } from 'xior'
import { getUser } from '~/apis/news/get-user'
import { newsLoginRequest } from '~/apis/news/login'
import { loginSchema, type TLoginSchema } from '~/layouts/news/form-login'
import { generateTokenCookie } from '~/utils/token'
@@ -27,6 +28,9 @@ export const action = async ({ request }: Route.ActionArgs) => {
const { data: loginData } = await newsLoginRequest(payload)
const { token } = loginData
const { data: userData } = await getUser({
accessToken: token,
})
const tokenCookie = generateTokenCookie({
token,
})
@@ -37,6 +41,7 @@ export const action = async ({ request }: Route.ActionArgs) => {
return data(
{
success: true,
user: userData,
},
{
headers,