4.0.0 • Published 8 years ago

eaze-request v4.0.0

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

eaze-request Build Status

Make requests to the Eaze API

Install

$ npm install --save eaze-request

Usage

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.

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

4.0.0

8 years ago

3.2.0

8 years ago

3.1.1

8 years ago

3.1.0

8 years ago

3.0.0

8 years ago

2.2.0

9 years ago

2.1.0

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.1.0

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago