Requestable

Requestable

Requestable wraps the logic for making http requests to the API

Constructor

new Requestable(authopt, apiBaseopt)

Initialize the http internals.

Parameters:
Name Type Attributes Default Description
auth Requestable.auth <optional>

the credentials to authenticate to Github. If auth is not provided request will be made unauthenticated

apiBase string <optional>
https://api.github.com

the base Github API URL

Source:

Methods

_dateToISO(date) → {string}

if a Date is passed to this function it will be converted to an ISO string

Parameters:
Name Type Description
date *

the object to attempt to cooerce into an ISO date string

Source:
Returns:
  • the ISO representation of date or whatever was passed in if it was not a date
Type
string

(protected) _getOptionsWithDefaults(requestOptionsopt) → {Object}

Sets the default options for API requests

Parameters:
Name Type Attributes Default Description
requestOptions Object <optional>
{}

the current options for the request

Source:
Returns:
  • the options to pass to the request
Type
Object

_request(method, path, dataopt, cbopt, rawopt) → {Promise}

Make a request.

Parameters:
Name Type Attributes Default Description
method string

the method for the request (GET, PUT, POST, DELETE)

path string

the path for the request

data * <optional>

the data to send to the server. For HTTP methods that don't have a body the data will be sent as query parameters

cb Requestable.callback <optional>

the callback for the request

raw boolean <optional>
false

if the request should be sent as raw. If this is a falsy value then the request will be made as JSON

Source:
Returns:
  • the Promise for the http request
Type
Promise

_request204or404(path, data, cb) → {Promise}

Make a request to an endpoint the returns 204 when true and 404 when false

Parameters:
Name Type Description
path string

the path to request

data Object

any query parameters for the request

cb Requestable.callback

the callback that will receive true or false

Source:
Returns:
  • the promise for the http request
Type
Promise

_requestAllPages(path, options, cbopt, results) → {Promise}

Make a request and fetch all the available data. Github will paginate responses so for queries that might span multiple pages this method is preferred to Requestable#request

Parameters:
Name Type Attributes Description
path string

the path to request

options Object

the query parameters to include

cb Requestable.callback <optional>

the function to receive the data. The returned data will always be an array.

results Array.<Object>

the partial results. This argument is intended for interal use only.

Deprecated:
Source:
Returns:
  • a promise which will resolve when all pages have been fetched
Type
Promise

Type Definitions

auth

Either a username and password or an oauth token for Github

Type:
  • Object
Properties:
Name Type Attributes Description
username string <optional>

the Github username

password string <optional>

the user's password

token token <optional>

an OAuth token

Source:

callback(error, result, request)

A function that receives the result of the API request.

Parameters:
Name Type Description
error Requestable.Error

the error returned by the API or null

result Object | true

the data returned by the API or true if the API returns 204 No Content

request Object

the raw Response

Source: