Skip to content

Latest commit

 

History

History
55 lines (41 loc) · 1.36 KB

README.md

File metadata and controls

55 lines (41 loc) · 1.36 KB

qs-stringify

Simple query stringify with nesting.

npm github standard

Install

npm install qs-stringify

Usage

var stringify = require('qs-stringify')

stringify({
  page: {
    offset: 50,
    limit: 25
  },
  filter: 'hello world'
})
// → "page[offset]=50&page[limit]=25&filter=hello%20world"

This module expects that you know the shape of the query string you want to print, and only does trivial serialization of strings, numbers, and nested objects. If you want to use other types or do custom serialization, fit them into a supported shape first:

var stringify = require('qs-stringify')

var startAt = new Date()
var filterTags = ['work', 'home']

stringify({
  tags: filterTags.join(','),
  startAt: startAt.toISOString(),
})
// → "tags=work,home&startAt=2024-10-15T20%3A22%3A36.883Z"

License

MIT