Provider API
Chain API
Once we have initialized a provider we can start using it through the Chain API:
google
.query('youtube')
.get('channels')
.qs({forUsername: 'CaseyNeistat'})
.auth('[ACCESS_TOKEN]')
.request((err, res, body) => ())
// or if Purest was initialized with Promises
var req = google
.query('youtube')
.get('channels')
.qs({forUsername: 'CaseyNeistat'})
.auth('[ACCESS_TOKEN]')
.request()
req
.catch((err) => {})
.then((result) => {})
Basic API
A Basic API is available as well:
provider_instance[HTTP_VERB]([endpoint], [options], [callback])
One additional api
key should be passed to the Purest's constructor to specify which API to use with this instance:
var google = purest({provider: 'google', config, api: 'basic'})
Then the Basic API can be used like this:
google.get('channels', {
alias: 'youtube',
auth: {bearer: '[ACCESS_TOKEN]'},
qs: {forUsername: 'CaseyNeistat'}
}, (err, res, body) => {})
// or if Purest was initialized with Promises
var req = google.get('channels', {
alias: 'youtube',
auth: {bearer: '[ACCESS_TOKEN]'},
qs: {forUsername: 'CaseyNeistat'}
})
req
.catch((err) => {})
.then((result) => {})