1.0.0 • Published 10 years ago
ghify-request-options v1.0.0
ghify-request-options
Create a Request option object that helps to interact with the GitHub API
const ghifyRequestOptions = require('ghify-request-options');
ghifyRequestOptions({method: 'POST'});
/* => {
method: 'POST',
json: true,
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'https://github.com/shinnn/ghify-request-options'
},
baseUrl: 'https://api.github.com'
}
*/ Installation
npm install ghify-request-optionsAPI
const ghifyRequest = require('ghify-request-options');ghifyRequestOptions(options)
options: Object (Request options to overwrite the defaults, and token option)
Return: Object (new Request options)
It returns Request options that defaults to the GitHub-API-friendly settings.
ghifyRequestOptions();
/* => {
json: true,
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'https://github.com/shinnn/ghify-request-options'
},
baseUrl: 'https://api.github.com'
}
*/ options.token
Type: String
Default: process.env.GITHUB_TOKEN
Use specific GitHub access token.
ghifyRequestOptions({
token: 'xxxxxxxxxxx' // your personal access token
});
/* => {
json: true,
token: 'xxxxxxx',
headers: {
accept: 'application/vnd.github.v3+json',
'user-agent': 'https://github.com/shinnn/ghify-request-options',
authorization: 'token xxxxxxxxxxx'
},
baseUrl: 'https://api.github.com'
}
*/options.baseUrl
Type: String
Default: process.env.GITHUB_ENDPOINT if available, otherwise 'https://api.github.com'
Use the different endpoint to support Github enterprise.
License
Copyright (c) 2015 Shinnosuke Watanabe
Licensed under the MIT License.