# Api

Kind: global class

# new Api()

Wrapper around json:api 1.0 requests, sets content type and other defaults.

# api.setSuccessCallbacks(callbacks)

Functions to be called after successful requests.

Kind: instance method of Api

Param Type
callbacks Array.<function()>

# api.setErrorCallbacks(callbacks)

Kind: instance method of Api

Param Type
callbacks Array.<function()>

# api.addSuccessCallback(callback)

Kind: instance method of Api

Param Type
callback function

# api.addErrorCallback(callback)

Kind: instance method of Api

Param Type
callback function

# api.resetSuccessCallbacks()

Reset the response success handling to the default behaviour

Kind: instance method of Api

# api.resetErrorCallbacks()

Reset the response error to the default behaviour

Kind: instance method of Api

# api.setHeader(name, value, overwrite)

Kind: instance method of Api

Param Type Default
name string
value string
overwrite boolean false

# api.addHeaders(headers)

Add multiple request headers at once by passing an object:

api.addHeaders({
  'X-My-Header': 'my-header-value',
  'E-Tag': '12923-434-123'
})

Kind: instance method of Api

Param Type
headers Object

# api._doRequest(method, url, params, data) ⇒ Promise.<Response>

Kind: instance method of Api
Access: protected

Param Type
method string
url string
params Object
data Object