datasquirel/package-shared/utils/serialize-query.js
Benjamin Toby 2ae4610dca Bugfix
2024-12-10 15:20:48 +01:00

19 lines
423 B
JavaScript

// @ts-check
/** @type {import("../types").SerializeQueryFnType} */
function serializeQuery({ query }) {
let str = "?";
const keys = Object.keys(query);
/** @type {string[]} */
const queryArr = [];
keys.forEach((key) => {
if (!key || !query[key]) return;
queryArr.push(`${key}=${query[key]}`);
});
str += queryArr.join("&");
return str;
}
module.exports = serializeQuery;