datasquirel/utils/functions/serialize-query.js
2024-10-18 06:45:25 +01:00

18 lines
396 B
JavaScript

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