parent
4fd4132f5e
commit
bd9df789d1
|
@ -1,9 +1,11 @@
|
|||
import { stringify } from 'querystring';
|
||||
|
||||
export function query(obj: {}): string {
|
||||
return stringify(Object.entries(obj)
|
||||
const params = Object.entries(obj)
|
||||
.filter(([, v]) => Array.isArray(v) ? v.length : v !== undefined)
|
||||
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>));
|
||||
.reduce((a, [k, v]) => (a[k] = v, a), {} as Record<string, any>);
|
||||
|
||||
return Object.entries(params)
|
||||
.map((e) => `${e[0]}=${e[1]}`)
|
||||
.join('&');
|
||||
}
|
||||
|
||||
export function appendQuery(url: string, query: string): string {
|
||||
|
|
Loading…
Reference in a new issue