[back to @octokit/rest
]('../..')
@octokit/rest/endpoint
Turn REST API endpoint options into generic request options
const octokitRestEndpoint = require('@octokit/rest/lib/endpoint')
const options = octokitRestEndpoint({
// request options
method: 'GET',
url: '/orgs/:org/repos',
// parameters
org: 'octokit',
type: 'private'
})
options
would now look something like
{
method: 'GET',
url: 'https://api.github.com/orgs/octokit/repos?type=private',
headers: {
'user-agent': 'octokit/rest.js v1.2.3',
accept: 'application/vnd.github.v3+json'
}
}
You can pass them to your request library of preference.
method
Any supported http verb, case insensitive.
url
A path or full URL which may contain :variable
or {variable}
placeholders,
e.g. /orgs/:org/repos
. The url
is parsed using
Name | Value |
---|---|
method | 'get' |
baseUrl | 'https://api.github.com' |
headers.accept | 'application/vnd.github.v3+json' |
headers.user-agent | 'octokit/rest.js v1.2.3' (1.2.3 being the current @octokit.rest version number) |
To be done: change defaults with
const octokitRestEndpoint = require('@octokit/rest/lib/endpoint').defaults({
baseUrl: 'http://my-custom-host/api/v3'
})