UNPKG

payload-rest-client

Version:

A typesafe rest api client for the payload cms.

37 lines 1.28 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createGlobalsProxy = void 0; const fetch_1 = require("./fetch"); const qs_1 = require("./qs"); const createGlobalsProxy = (options) => { const fetchFn = (0, fetch_1.fetchFactory)(options); return new Proxy({}, { get: (_, slug) => { const api = { get: (params) => { return fetchFn({ type: "global", slug, method: "GET", path: ["globals", slug], qs: (0, qs_1.createQueryString)(params), }); }, update: (params) => { const { patch, ...rest } = params; return fetchFn({ type: "global", slug, method: "POST", path: ["globals", slug], qs: (0, qs_1.createQueryString)(rest), body: patch, }); }, }; return api; }, }); }; exports.createGlobalsProxy = createGlobalsProxy; //# sourceMappingURL=globalsProxy.js.map