feat: implement HttpServer for API requests and add getUser function for user profile retrieval
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { z } from 'zod'
|
||||
|
||||
import { HttpServer, type THttpServer } from '~/libs/http-server'
|
||||
|
||||
const playerSchema = z.object({
|
||||
data: z.object({
|
||||
id: z.string(),
|
||||
email: z.string(),
|
||||
subscribe_plan_code: z.string(),
|
||||
subscribe_plan_name: z.string(),
|
||||
subscribe_status: z.string(),
|
||||
}),
|
||||
})
|
||||
|
||||
export const getUser = async (parameters: THttpServer) => {
|
||||
try {
|
||||
const { data } = await HttpServer(parameters).get(`/api/user/profile`)
|
||||
return playerSchema.parse(data)
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line unicorn/no-useless-promise-resolve-reject
|
||||
return Promise.reject(error)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user