mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2025-06-04 11:13:59 +08:00
chore: Change network request method
This commit is contained in:
parent
a1ba4e273e
commit
b46209e164
25
backend/src/vendor/open-api.js
vendored
25
backend/src/vendor/open-api.js
vendored
@ -376,25 +376,16 @@ export function HTTP(defaultOptions = { baseURL: '' }) {
|
|||||||
});
|
});
|
||||||
} else if (isGUIforCores) {
|
} else if (isGUIforCores) {
|
||||||
worker = new Promise(async (resolve, reject) => {
|
worker = new Promise(async (resolve, reject) => {
|
||||||
const requestHandler = {
|
|
||||||
get: $Plugins.HttpGet,
|
|
||||||
head: $Plugins.HttpHead,
|
|
||||||
post: $Plugins.HttpPost,
|
|
||||||
put: $Plugins.HttpPut,
|
|
||||||
delete: $Plugins.HttpDelete,
|
|
||||||
};
|
|
||||||
const request = requestHandler[method.toLowerCase()];
|
|
||||||
if (!request)
|
|
||||||
reject(
|
|
||||||
'[GUI.for.Cores] This method is not implemented: ' +
|
|
||||||
method,
|
|
||||||
);
|
|
||||||
try {
|
try {
|
||||||
const { url, headers } = options;
|
const response = await $Plugins.Requests({
|
||||||
const response = await request(url, headers, options.body);
|
method,
|
||||||
|
url: options.url,
|
||||||
|
headers: options.headers,
|
||||||
|
body: options.body,
|
||||||
|
});
|
||||||
resolve({
|
resolve({
|
||||||
statusCode: response.status ?? 200,
|
statusCode: response.status,
|
||||||
headers: response.header,
|
headers: response.headers,
|
||||||
body: response.body,
|
body: response.body,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user