utils/request

utils/request

Methods

(static) checkStatus(response) → {response|Error}

Source:

Checks if a network request came back fine, and throws an error if not

Parameters:
Name Type Description
response object

A response from a network request

Returns:

Returns either the response, or throws an error

Type
response | Error

(static) exports.requestGet(url, session) → {response}

Source:

Requests a URL, returning a promise

Parameters:
Name Type Description
url string

The URL we want to request

session boolean

Indicates is check session using in that API

Returns:

The response data

Type
response

(static) exports.requestPost(url, data, session) → {response}

Source:

Requests a URL, returning a promise

Parameters:
Name Type Description
url string

The URL we want to request

data object

The data we want to pass to API

session boolean

Indicates is check session using in that API

Returns:

The response data

Type
response

(static) requestCheckSession(response, session) → {response}

Source:

Open session expired modal

Parameters:
Name Type Description
response object
session boolean
Returns:
Type
response

(static) requestParseJSON(response) → {response}

Source:

Parses the JSON returned by a network request

Parameters:
Name Type Description
response object

A response from a network request

Returns:

The parsed JSON from the request

Type
response

Type Definitions

error

Source:
Properties:
Name Type Description
code number

Unique message code number

message string

Cause of an error

Type:
  • object

response

Source:
Properties:
Name Type Description
status number

Represent boolean, -1 is error, 1 is success

error error

Only exist when status is -1

data object

Only exist when status is 1

Type:
  • object