1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-22 04:54:18 +00:00
pds-2021-g2-nest/nest_frontend/utils/makeURLSearchParams.js

19 lines
No EOL
416 B
JavaScript

import isString from "is-string"
export default function makeURLSearchParams(obj) {
let usp = new URLSearchParams()
for(const key in obj) {
if(!obj.hasOwnProperty(key)) {
return
}
const value = obj[key]
if(isString(value)) {
usp.set(key, value)
}
else {
usp.set(key, JSON.stringify(value))
}
}
return usp
}