0.0.4 • Published 1 year ago

@kbco/query-builder v0.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

npm NPM npm

node-http-query-builder

I just wanted an easy way to convert objects into query strings. I was tired of not having a decent option...

Installation

npm install --save @kbco/query-builder
yarn add @kbco/query-builder

Usage

const { buildUrl } = require('@kbco/query-builder')

let url = buildUrl('/your-route-to-build-a-query-for', {
    option: 'do build something for',
    objectThing: {
        'a key-value pair': 'of values'
    },
    arrayThing: ['array', 'of', 'values'],
})

// The url value would be '/your-route-to-build-a-query-for?option=do%20build%20something%20for&objectThing[a%20key-value%20pair]=of%20valuesarrayThing=array,of,values'
// then use your favorite ajax lib to make a call against that URL. (For me I like axios)
axios.get(url)
    .then(({ data })=> {
        // do something with the returned data.
    })