48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { ofetch } from "ofetch";
|
|
|
|
const httpFetchClient = {
|
|
get: async (url: string, headers: Record<string, string>) => {
|
|
const response = await ofetch(url, {
|
|
method: "GET",
|
|
headers,
|
|
});
|
|
|
|
return response;
|
|
},
|
|
post: async (url: string, body: JSON, headers: Record<string, string>) => {
|
|
const response = await ofetch(url, {
|
|
method: "POST",
|
|
headers,
|
|
body: JSON.stringify(body),
|
|
});
|
|
|
|
return response;
|
|
},
|
|
put: async (url: string, body: JSON, headers: Record<string, string>) => {
|
|
const response = await ofetch(url, {
|
|
method: "PUT",
|
|
headers,
|
|
body: JSON.stringify(body),
|
|
});
|
|
|
|
return response;
|
|
},
|
|
patch: async (url: string, body: JSON, headers: Record<string, string>) => {
|
|
const response = await ofetch(url, {
|
|
method: "PATCH",
|
|
headers,
|
|
body: JSON.stringify(body),
|
|
});
|
|
|
|
return response;
|
|
},
|
|
delete: async (url: string, headers: Record<string, string>) => {
|
|
const response = await ofetch(url, {
|
|
method: "DELETE",
|
|
headers,
|
|
});
|
|
|
|
return response;
|
|
},
|
|
};
|
|
export default httpFetchClient;
|