19 lines
444 B
TypeScript
19 lines
444 B
TypeScript
export const get = async (url: string) => {
|
|
const resp = await fetch(url);
|
|
const json = await resp.json();
|
|
return json;
|
|
};
|
|
export const post = async (
|
|
url: string,
|
|
json: any,
|
|
headers: Record<string, string> = {}
|
|
) => {
|
|
const resp = await fetch(url, {
|
|
method: "POST",
|
|
headers: { "Content-Type": "application/json", ...headers },
|
|
body: JSON.stringify(json),
|
|
});
|
|
const result = await resp.json();
|
|
return result;
|
|
};
|