This commit is contained in:
2026-01-01 09:22:51 +01:00
parent b8e5d45762
commit 8277ff3e41
8 changed files with 31 additions and 35 deletions
+1 -1
View File
@@ -7,4 +7,4 @@ export default function clientCrudFetch<T extends {
[k: string]: any;
} = {
[k: string]: any;
}>({ table, basePath, body, query, targetId, method, apiOrigin, headers, }: ClientCrudFetchParams<T, P>): Promise<APIResponseObject<PostInsertReturn | R[]>>;
}>({ table, basePath, body, query, targetId, method, apiOrigin, headers, ...options }: ClientCrudFetchParams<T, P>): Promise<APIResponseObject<PostInsertReturn | R[]>>;
+15 -5
View File
@@ -8,6 +8,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
@@ -16,7 +27,8 @@ exports.default = clientCrudFetch;
const serialize_query_1 = __importDefault(require("../../package-shared/utils/serialize-query"));
const fetch_1 = __importDefault(require("../fetch"));
function clientCrudFetch(_a) {
return __awaiter(this, arguments, void 0, function* ({ table, basePath, body, query, targetId, method = "GET", apiOrigin, headers, }) {
return __awaiter(this, void 0, void 0, function* () {
var { table, basePath, body, query, targetId, method = "GET", apiOrigin, headers } = _a, options = __rest(_a, ["table", "basePath", "body", "query", "targetId", "method", "apiOrigin", "headers"]);
try {
let pathname = basePath || ``;
pathname += `/${String(table)}`;
@@ -30,11 +42,9 @@ function clientCrudFetch(_a) {
pathname = apiOrigin
? `${apiOrigin}/${pathname}`.replace(/([^:]\/)\/+/g, "$1")
: pathname;
const res = yield (0, fetch_1.default)(pathname, {
method,
const res = yield (0, fetch_1.default)(pathname, Object.assign({ method,
body,
headers,
});
headers }, options));
return res;
}
catch (error) {