query and urlencoded parsing for micro
Parse query strings and form-urlencoded bodies for Zeit's Micro.
Install
yarn add micro-urlencoded# or npm install --save micro-urlencoded
Usage
The first argument to micro-urlencoded may be a string, Node Buffer, an async handler function, or an IncomingMessage object (or similar enough to one for micro.buffer()
).
const query = ;
string
moduleexports = { const url = 'https://example.com/whatever?query=starts&here=2'; const queryString = ; const queryObject = ; };
Buffer
moduleexports = { const buffer = micro; // do other things with the request body buffer... // if the buffer is url-encoded const body = ; };
IncomingMessage
moduleexports = { const query body = ; };
function
const handler = async { // your handler code}; moduleexports = ;
License
The Unlicense, which is to say, public domain unless a license is required in your jurisdiction, in which case please follow the LICENSE file.