mirror of
https://github.com/DefectingCat/DefectingCat.github.io
synced 2025-07-16 01:01:38 +00:00
* update prisma * Add search API in page * add API with fetch * Update search with global state
24 lines
425 B
TypeScript
24 lines
425 B
TypeScript
import { SearchType } from 'lib/API/types';
|
|
|
|
const search = async (q: string, page = 1) => {
|
|
const body = {
|
|
q,
|
|
page,
|
|
};
|
|
|
|
const response = await fetch('/api/search', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(body),
|
|
});
|
|
|
|
if (response.ok) {
|
|
const result: SearchType = await response.json();
|
|
return result;
|
|
}
|
|
};
|
|
|
|
export { search };
|