UNPKG

payload-rest-client

Version:

A typesafe rest api client for the payload cms.

28 lines 993 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.createQueryString = void 0; const createQueryString = (params) => { if (!params) { return ""; } const encodeQuery = (key, value) => { // return `${key}=${encodeURIComponent(value)}`; return `${key}=${value}`; }; const buildQueryString = (obj, parentKey) => { const parts = Object.entries(obj).map(([key, value]) => { const currentKey = parentKey ? `${parentKey}[${key}]` : key; if (value instanceof Date) { return encodeQuery(currentKey, value.toISOString()); } if (typeof value === "object") { return buildQueryString(value, currentKey); } return encodeQuery(currentKey, value); }); return parts.join("&"); }; return buildQueryString(params, ""); }; exports.createQueryString = createQueryString; //# sourceMappingURL=qs.js.map