mirror of
https://github.com/danbulant/Portfolio
synced 2026-06-17 21:41:20 +00:00
feat: add csv to API
This commit is contained in:
parent
978aea863a
commit
0dd7315621
1 changed files with 20 additions and 0 deletions
|
|
@ -120,3 +120,23 @@ export const apiFetchCandidate = async (id: number, fetchSsr?: Fetch): Promise<C
|
|||
throw errorHandler(e, 'Failed to fetch candidate data');
|
||||
}
|
||||
};
|
||||
|
||||
// SSR compatible
|
||||
// List all candidates /admin/list/candidates
|
||||
export const apiListCandidatesCSV = async (
|
||||
fetchSsr?: Fetch,
|
||||
): Promise<Blob> => {
|
||||
const apiFetch = fetchSsr || fetch;
|
||||
try {
|
||||
const res = await apiFetch(API_URL + '/admin/list/candidates_csv', {
|
||||
method: 'GET',
|
||||
credentials: 'include'
|
||||
});
|
||||
if (res.status != 200) {
|
||||
throw Error(await res.text());
|
||||
}
|
||||
return await res.blob();
|
||||
} catch (e) {
|
||||
throw errorHandler(e, 'List candidates CSV failed');
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue