fuc-new/doc/node_modules/vuepress-plugin-md-power/lib/client/utils/http.js
hellcat 6adbc04d4b 1
2025-10-03 17:17:08 +08:00

18 lines
500 B
JavaScript

//#region src/client/utils/http.ts
const http = {
get: async (url, query) => {
const _url = new URL(url);
if (query) for (const [key, value] of Object.entries(query)) _url.searchParams.append(key, value);
return await (await fetch(_url.toString())).json();
},
post: async (url, data) => {
return await (await fetch(url, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: data ? JSON.stringify(data) : void 0
})).json();
}
};
//#endregion
export { http };