chore: perauset customer project
This commit is contained in:
58
e2e/tests/support/api-client.ts
Normal file
58
e2e/tests/support/api-client.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
function buildHeaders(cookies?: string): Record<string, string> {
|
||||
const headers: Record<string, string> = {
|
||||
'Content-Type': 'application/json',
|
||||
Accept: 'application/json',
|
||||
}
|
||||
if (cookies) {
|
||||
headers['Cookie'] = cookies
|
||||
}
|
||||
return headers
|
||||
}
|
||||
|
||||
export async function apiGet(
|
||||
url: string,
|
||||
path: string,
|
||||
cookies?: string
|
||||
): Promise<Response> {
|
||||
return fetch(`${url}${path}`, {
|
||||
method: 'GET',
|
||||
headers: buildHeaders(cookies),
|
||||
})
|
||||
}
|
||||
|
||||
export async function apiPost(
|
||||
url: string,
|
||||
path: string,
|
||||
body: any,
|
||||
cookies?: string
|
||||
): Promise<Response> {
|
||||
return fetch(`${url}${path}`, {
|
||||
method: 'POST',
|
||||
headers: buildHeaders(cookies),
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
}
|
||||
|
||||
export async function apiPut(
|
||||
url: string,
|
||||
path: string,
|
||||
body: any,
|
||||
cookies?: string
|
||||
): Promise<Response> {
|
||||
return fetch(`${url}${path}`, {
|
||||
method: 'PUT',
|
||||
headers: buildHeaders(cookies),
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
}
|
||||
|
||||
export async function apiDelete(
|
||||
url: string,
|
||||
path: string,
|
||||
cookies?: string
|
||||
): Promise<Response> {
|
||||
return fetch(`${url}${path}`, {
|
||||
method: 'DELETE',
|
||||
headers: buildHeaders(cookies),
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user