Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/writetome51/get-url-query
Javascript functions: one takes in key : value pairs (a literal object) and returns a url-encoded query string. The other takes a url-encoded query string and returns an object.
https://github.com/writetome51/get-url-query
get get-request javascript parser query-string query-string-builder typescript url
Last synced: 1 day ago
JSON representation
Javascript functions: one takes in key : value pairs (a literal object) and returns a url-encoded query string. The other takes a url-encoded query string and returns an object.
- Host: GitHub
- URL: https://github.com/writetome51/get-url-query
- Owner: writetome51
- License: mit
- Created: 2019-08-16T20:29:47.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-06T23:13:52.000Z (over 4 years ago)
- Last Synced: 2024-12-09T07:07:11.437Z (25 days ago)
- Topics: get, get-request, javascript, parser, query-string, query-string-builder, typescript, url
- Language: TypeScript
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# getURLQuery(
keyValuePairs: object
): stringConverts `keyValuePairs` to a URI-encoded query string and returns it.
# getObjectFromURLQuery(
urlQuery: string
): objectPerforms the reverse of `getURLQuery()`.
Decodes `urlQuery` and returns it as an object of key-value pairs.## Examples
```js
let urlQuery = getURLQuery(
{name:'joe schmoe', email:'[email protected]', password:'&Å͆'}
);
// urlQuery === '?name=joe%20schmoe&email=jschmoe%40gmail.com&password=%26%C3%85%C3%8D%E2%80%A0'// You can decode the information by passing it to getObjectFromURLQuery():
getObjectFromURLQuery(urlQuery);
// --> { name: 'joe schmoe', email: '[email protected]', password: '&Å͆' }
```## Installation
```bash
npm i @writetome51/get-url-query
```## Loading
```js
import {getURLQuery, getObjectFromURLQuery} from '@writetome51/get-url-query';
```