# blitz-js-query-browser

> Blitz-js API connection module optimized for usage in browsers

Latest version **0.3.2** (published 2018-02-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install blitz-js-query-browser
pnpm add blitz-js-query-browser
yarn add blitz-js-query-browser
bun add blitz-js-query-browser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.2 |
| Published | 2018-02-23 |
| First published | 2017-08-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 265.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kaptard |
| Maintainers | kaptard |

## Links

- npm: https://www.npmjs.com/package/blitz-js-query-browser
- Repository: https://github.com/nexus-devs/npm-blitz-query
- Homepage: https://github.com/nexus-devs/npm-blitz-query#readme
- Issues: https://github.com/nexus-devs/npm-blitz-query/issues
- npm.io page: https://npm.io/package/blitz-js-query-browser

## Dependencies (2)

- [socket.io-client](https://npm.io/package/socket.io-client.md) ^2.0.4
- [async-delay-queue](https://npm.io/package/async-delay-queue.md) ^1.0.7

## Recent versions

- 0.3.2 (latest) — 2018-02-23
- 0.3.1 — 2018-02-16
- 0.3.0 — 2018-02-16
- 0.2.19 — 2018-01-12
- 0.2.8 — 2017-12-14
- 0.2.7 — 2017-10-22
- 0.2.6 — 2017-10-22
- 0.2.5 — 2017-10-17
- 0.2.4 — 2017-10-17
- 0.2.3 — 2017-09-04
- 0.2.2 — 2017-09-04
- 0.2.1 — 2017-09-04
- 0.2.0 — 2017-08-27
- 0.1.9 — 2017-08-26
- 0.1.3 — 2017-08-26
- … 3 more at https://npm.io/package/blitz-js-query-browser/versions

## README

[![Blitz.js API Connection Package](/banner.png)](https://github.com/nexus-devs)

##

Connection packages to connect to <a href="https://github.com/nexus-devs/blitz-js-api">blitz.js</a> API nodes. Choose your target platform from the available branches.

<br>


## Installation
`npm install blitz-js-query`

<br>

## Other Supported Platforms

| Platform           | Install        | Description   |
|:------------- |:------------- |:------------- |
| [python](https://github.com/nexus-devs/blitz-js-query/tree/python) | pip | For usage in Python. Official Socket.io version updates are slow, HTTP might have to be explicitly enabled |

<br>

## Usage
```js
const Blitz = require("blitz-js-query")
const blitz = new Blitz()

blitz.get("/foo").then(res => console.log(res.body)) // bar
```

<br>

## Configuration
```javascript
const Blitz = require("blitz-js-query")
const blitz = new Blitz({key: value})
```

| Key           | Default         | Description   |
|:------------- |:------------- |:------------- |
| api_url | "http://localhost:3010/" | URL of blitz.js API-Node to connect to |
| auth_url | "http://localhost:3030/" | URL of blitz.js Auth-Node to authenticate with |
| namespace | "/" | Socket.io namespace to connect to |
| user_key | null | User key obtained via Auth-Node registration |
| user_secret | null | User secret obtained via Auth-Node |
| ignore_limiter | false | Whether or not to disable the default rate limit adaptions. Disabling this only makes sense if you connect as a user who won't face rate limits. If you disable it anyway, expect all your requests to get blocked. |

<br>
<br>

## API

### RESTful methods
```js
blitz.get(url)
```
>Sends a GET request to the API-Node

| Argument | Description | Default |
|:------------- |:------------- |:------------- |
| url | URL to request, without domain. e.g. `/foo`. | None |

<br>

```js
blitz.post(url, body)
```
>Sends a POST request to the API-Node

| Argument | Description | Default |
|:------------- |:------------- |:------------- |
| url | URL to request, without domain. e.g. `/foo`. | None |
| body | Data to send to endpoint. Can be any data type. | None |

<br>

```js
blitz.put(url, body)
```
>Sends a PUT request to the API-Node

| Argument | Description | Default |
|:------------- |:------------- |:------------- |
| url | URL to request, without domain. e.g. `/foo`. | None |
| body | Data to send to endpoint. Can be any data type. | None |

<br>

```js
blitz.patch(url, body)
```
>Sends a PATCH request to the API-Node

| Argument | Description | Default |
|:------------- |:------------- |:------------- |
| url | URL to request, without domain. e.g. `/foo`. | None |
| body | Data to send to endpoint. Can be any data type. | None |

<br>

```js
blitz.delete(url, body)
```
>Sends a DELETE request to the API-Node

| Argument | Description | Default |
|:------------- |:------------- |:------------- |
| url | URL to request, without domain. e.g. `/foo`. | None |
| body | Data to send to endpoint. Can be any data type. | None |

<br>

### Socket.io

```js
blitz.subscribe(endpoint)
```
>Subscribe to updates on a specific endpoint. Updates can be listened to via `blitz.on(endpoint, fn)`.

| Argument | Description | Default |
|:------------- |:------------- |:------------- |
| endpoint | URL to listen for updates on, without domain. e.g. `/foo` | None |

<br>

```js
blitz.on(ev, fn)
```
>Listens to specific Socket.io event, then runs the given function with the received data

| Argument | Description | Default |
|:------------- |:------------- |:------------- |
| ev | Event name. | None |
| fn | Function to execute on event trigger | None |

<br>

```js
blitz.emit(ev, data)
```
>Emits event via Socket.io client to server

| Argument | Description | Default |
|:------------- |:------------- |:------------- |
| ev | Event name. | None |
| data | Data to transmit. Can be any data type. | None |

<br>


## License
[MIT](https://github.com/nexus-devs/npm-blitz-query/blob/master/LICENSE.md)

---
_Source: https://npm.io/package/blitz-js-query-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
