feat: create kyc page with api
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { api } from '@shared/api/base'
|
||||
import { KYC_API_URL } from '@shared/config/env'
|
||||
import { getCsrfToken } from '@shared/api/csrf'
|
||||
import { tokenStore } from '@shared/api/tokenStore'
|
||||
|
||||
export interface KycResponse {
|
||||
status: boolean
|
||||
@@ -9,6 +11,22 @@ export interface KycResponse {
|
||||
qr_code: string
|
||||
}
|
||||
|
||||
export function kycCreate(): Promise<KycResponse> {
|
||||
return api.post<KycResponse>('/kyc/create', {})
|
||||
export async function kycCreate(): Promise<KycResponse> {
|
||||
const csrf = await getCsrfToken()
|
||||
const bearer = tokenStore.get()
|
||||
|
||||
const res = await fetch(`${KYC_API_URL}/kyc/create`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': csrf,
|
||||
...(bearer ? { Authorization: `Bearer ${bearer}` } : {}),
|
||||
},
|
||||
body: JSON.stringify({}),
|
||||
})
|
||||
|
||||
const data = await res.json()
|
||||
if (!res.ok) throw data
|
||||
return data as KycResponse
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user