openblox
Version:
Roblox API Wrapper For Both Classic And OpenCloud APIs.
44 lines (43 loc) • 1.73 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var fetchHttpAdapter_exports = {};
__export(fetchHttpAdapter_exports, {
FetchAdapter: () => FetchAdapter
});
module.exports = __toCommonJS(fetchHttpAdapter_exports);
var import_http = require("../http.utils");
const getBody = async (response, contentType) => {
return contentType?.startsWith("application/json") ? await response.json() : await response.text();
};
const FetchAdapter = async ({ url, method, headers, body, formData }) => {
const response = await fetch(url, { method, headers, body: formData || body, cache: "no-store", credentials: "include" });
return new import_http.HttpResponse({
url,
method,
success: response.ok,
statusCode: response.status,
headers: response.headers,
body: await getBody(response, response.headers.get("content-type")),
fullResponse: response
});
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
FetchAdapter
});
;