Movatterモバイル変換


[0]ホーム

URL:


Requestable

Requestable

Requestable wraps the logic for making http requests to the API

Constructor

new Requestable(authopt, apiBaseopt, AcceptHeaderopt)

Initialize the http internals.

Parameters:
NameTypeAttributesDefaultDescription
authRequestable.auth <optional>

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

apiBasestring <optional>
https://api.github.com

the base Github API URL

AcceptHeaderstring <optional>
v3

the accept header for the requests

Source:

Methods

_dateToISO(date) → {string}

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

Parameters:
NameTypeDescription
date*

the object to attempt to cooerce into an ISO date string

Source:
Returns:
  • the ISO representation ofdate 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:
NameTypeAttributesDefaultDescription
requestOptionsObject <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:
NameTypeAttributesDefaultDescription
methodstring

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

pathstring

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

cbRequestable.callback <optional>

the callback for the request

rawboolean <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, methodopt) → {Promise}

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

Parameters:
NameTypeAttributesDefaultDescription
pathstring

the path to request

dataObject

any query parameters for the request

cbRequestable.callback

the callback that will receivetrue orfalse

methodmethod <optional>
GET

HTTP Method to use

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 queriesthat might span multiple pages this method is preferred toRequestable#request

Parameters:
NameTypeAttributesDescription
pathstring

the path to request

optionsObject

the query parameters to include

cbRequestable.callback <optional>

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

resultsArray.<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:
Properties:
NameTypeAttributesDescription
usernamestring <optional>

the Github username

passwordstring <optional>

the user's password

tokentoken <optional>

an OAuth token

Source:

callback(error, result, request)

A function that receives the result of the API request.

Parameters:
NameTypeDescription
errorRequestable.Error

the error returned by the API ornull

resultObject|true

the data returned by the API ortrue if the API returns204 No Content

requestObject

the rawResponse

Source:


[8]ページ先頭

©2009-2025 Movatter.jp