Skip to content

austinkregel/node-http-query-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.
    })

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published