# eaze-request

> Make requests to the Eaze API

Latest version **4.0.0** (published 2016-10-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install eaze-request
pnpm add eaze-request
yarn add eaze-request
bun add eaze-request
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2016-10-14 |
| First published | 2015-09-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 10 |
| Known vulnerabilities | 0 (+8 in 1 direct dependencies) |
| Install scripts | no |
| Author | Ben Drucker |
| Maintainers | bendrucker |
| Keywords | eaze, request, api |

## Links

- npm: https://www.npmjs.com/package/eaze-request
- Repository: https://github.com/eaze/eaze-request
- Homepage: https://github.com/eaze/eaze-request#readme
- Issues: https://github.com/eaze/eaze-request/issues
- npm.io page: https://npm.io/package/eaze-request

## Dependencies (10)

- [geval](https://npm.io/package/geval.md) ~2.1.1
- [xtend](https://npm.io/package/xtend.md) ~4.0.0
- [is-obj](https://npm.io/package/is-obj.md) ~1.0.0
- [url-join](https://npm.io/package/url-join.md) 0.0.1
- [url-parse](https://npm.io/package/url-parse.md) ~1.0.5
- [xhr-request](https://npm.io/package/xhr-request.md) ~1.0.1
- [is-error-code](https://npm.io/package/is-error-code.md) ~1.0.0
- [safe-json-parse](https://npm.io/package/safe-json-parse.md) ~4.0.0
- [http-status-error](https://npm.io/package/http-status-error.md) ~1.1.1
- [query-string-flatten](https://npm.io/package/query-string-flatten.md) ~1.0.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 4.0.0 (latest) — 2016-10-14
- 3.2.0 — 2016-07-22
- 3.1.1 — 2016-04-27
- 3.1.0 — 2016-03-17
- 3.0.0 — 2016-01-18
- 2.2.0 — 2015-11-06
- 2.1.0 — 2015-10-02
- 2.0.2 — 2015-09-19
- 2.0.1 — 2015-09-16
- 2.0.0 — 2015-09-15
- 1.1.0 — 2015-09-12
- 1.0.1 — 2015-09-07
- 1.0.0 — 2015-09-07

## README

# eaze-request [![Build Status](https://travis-ci.org/eaze/eaze-request.svg?branch=master)](https://travis-ci.org/eaze/eaze-request)

> Make requests to the Eaze API


## Install

```
$ npm install --save eaze-request
```


## Usage

```js
var Eaze = require('eaze-request')

var request = Eaze({baseUrl: 'https://the/api/base'})
request('the/endpoint', options, function (err, data) {
  //=> err = null / Error
  //=> data = {...} / undefined
})
```

## API

#### `Eaze(options)` -> `function`

Returns the `request` function.

##### options

Type: `object`
Default: `{baseUrl: '', method: 'get', json: true, timeout: 15000}`

Default options to be used with all requests made by the client.


#### `request(path, [options], [callback])` -> `request`

##### path

*Required*  
Type: `string`

The API request path.

##### options

Request settings, mostly passed to [xhr-request](https://github.com/Jam3/xhr-request).

Type: `object`  
Default: `{}`

###### token

Type: `string`

A token to use as the `X-Auth-Token` header.

##### callback

Type: `function`  
Arguments: `err, data`

###### err

Type: `error`

A request error. Responses with non-200 range status codes are considered errors. If the server sent an error message, that message will be used. Errors will always have a `statusCode` property.

###### data

Type: `object`

The JSON response data.

#### `request.onResult(listener)` -> `function`

Listens on all responses. Returns an unlisten function.

##### listener

Type: `function`  
Arguments: `data`

`data` contains:
* `method`
* `path`
* `query`
* `status`
* `times` (`{start, end}`)
* `duration`

## License

MIT © [Ben Drucker](http://bendrucker.me)

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