This commit is contained in:
xion 2025-03-30 00:36:51 +08:00
parent fd5437292a
commit 0570acb78f
2 changed files with 9 additions and 2 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@kevisual/query",
"version": "0.0.15-alpha.1",
"version": "0.0.15",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "dist/index.d.ts",

View File

@ -22,7 +22,14 @@ export const adapter = async (opts: AdapterOpts, overloadOpts?: RequestInit) =>
controller.abort();
}, timeout);
let method = overloadOpts?.method || opts.method || 'POST';
let url = new URL(opts.url, window.location.origin);
let origin = '';
let url: URL;
if (opts?.url?.startsWith('http')) {
url = new URL(opts.url);
} else {
origin = window?.location?.origin || 'http://localhost:11015';
url = new URL(opts.url, origin);
}
const isGet = method === 'GET';
if (isGet) {
url.search = new URLSearchParams(opts.body).toString();