decord/source/6280_enhancedFetch.js

45 lines
1.1 KiB
JavaScript
Raw Normal View History

2026-07-25 08:10:48 +00:00
// Module ID: 6280
// Function ID: 56533
2026-07-20 16:05:17 +00:00
// Name: enhancedFetch
2026-07-23 10:11:24 +00:00
// Dependencies: [5]
2026-07-20 16:05:17 +00:00
2026-07-25 08:10:48 +00:00
// Module 6280 (enhancedFetch)
2026-07-23 10:11:24 +00:00
import asyncGeneratorStep from "asyncGeneratorStep";
2026-07-20 16:05:17 +00:00
2026-07-23 10:11:24 +00:00
export const enhancedFetch = (() => {
callback = callback(async (arg0, arg1) => {
2026-07-20 16:05:17 +00:00
let obj = {};
let method;
if (null != arg1) {
method = arg1.method;
}
let str = "GET";
if (null != method) {
str = method;
}
obj.method = str;
2026-07-23 10:11:24 +00:00
obj.headers = { Accept: "application/json", "Content-Type": "application/json" };
2026-07-20 16:05:17 +00:00
if (null != arg1) {
if (arg1.body) {
obj = {};
const _JSON = JSON;
obj.body = JSON.stringify(arg1.body);
}
const obj3 = yield fetch(arg0, Object.assign(obj, {}));
if (obj3.ok) {
return obj3.json();
} else {
const _Object = Object;
const _Error = Error;
const error = new Error(obj3.statusText);
obj = { statusCode: obj3.status };
throw Object.assign(error, obj);
}
}
});
return function enhancedFetch(combined) {
return callback(...arguments);
};
2026-07-23 10:11:24 +00:00
})();