Stringify objects as Strings(Custom Splicing).
npm i --save object2string
const object2string = require('object2string')
const query = object2string({
name: 'yumcc',
age: 24,
gender: 1,
height: 170,
weight: 65,
blog: 'https://www.yumcc.com'
})
returns
name=yumcc&age=24&gender=1&height=170&weight=65&blog=https://www.yumcc.com
const query = object2string({
name: 'yumcc',
age: 24,
gender: 1,
height: 170,
weight: 65,
blog: 'https://www.yumcc.com'
}, {
sort: true, // default: false
splicing: '|', // default: &
relative: ':', // default: =
encode: [ 'blog' ] // default: []
})
returns
age:24|blog:https%3A%2F%2Fwww.yumcc.com|gender:1|height:170|name:yumcc|weight:65