# rest-io-client

> Promise based rest-io-router client socket implementation

Latest version **0.2.0** (published 2020-03-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install rest-io-client
pnpm add rest-io-client
yarn add rest-io-client
bun add rest-io-client
```

## 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.2.0 |
| Published | 2020-03-22 |
| First published | 2016-06-11 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 22.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | jjwtay |

## Links

- npm: https://www.npmjs.com/package/rest-io-client
- Repository: https://github.com/jjwtay/rest-io-client
- Homepage: https://github.com/jjwtay/rest-io-client#readme
- Issues: https://github.com/jjwtay/rest-io-client/issues
- npm.io page: https://npm.io/package/rest-io-client

## Dependencies (1)

- [socket.io-client](https://npm.io/package/socket.io-client.md) ^2.3.0

## Recent versions

- 0.2.0 (latest) — 2020-03-22
- 0.1.4 — 2019-02-15
- 0.1.3 — 2018-10-03
- 0.1.2 — 2016-06-14
- 0.1.1 — 2016-06-14
- 0.1.0 — 2016-06-11

## README

# rest-io-client

## Client es6 class for Promise based websocket requests to server implementing rest-io-router

## Installation &nbsp;
**With [node](http://nodejs.org) [installed]:**
```sh

$ npm install rest-io-client --save
```

## Usage 

```sh
	import RestSocket from 'rest-io-client'

	/*
		class RestSocket

		params:
			url: required
			options: optional socket.io options object
	*/
	var socket = new RestSocket(url)

	socket.get("/users").then(data => {
		...
	})
```

## API 

```sh
	get(url[, params, query]).then(data => {..}).catch(err => {...})
	post(url[, params, query]).then(data => {..}).catch(err => {...})
	put(url[, params, query]).then(data => {..}).catch(err => {...})
	delete(url[, params, query]).then(data => {..}).catch(err => {...})

	*Note*
	params = any valid js object
	query = any valid js object
```

### url may also contain query strings as below

```sh
	get("/users?id=foo").then(.....
```

### Emitting/Receiving via socket.io 

```sh
	import RestSocket from 'rest-io-client'

	var socket = new RestSocket(url)

	socket.on('foo', msg => {...})
	socket.emit('bar', data)

	*Note Reserved for Promise based API*
	socket.on('rest',...
	socket.emit('rest',...
```

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