mirror of
https://github.com/pds-nest/nest.git
synced 2024-12-01 17:04:19 +00:00
19 lines
No EOL
416 B
JavaScript
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
|
|
} |