@bearer/node
Node client to query any APIs and custom functions using Bearer.sh
Usage
Get your Bearer's credentials and setup Bearer as follow:
Calling any APIs
// or// import bearer from '@bearer/node' github .get'/repositories' .thenconsole.log .catchconsole.error
More advanced examples:
// With query parametersgithub .get'/repositories', .thenconsole.log .catchconsole.error // Making an authenticated POSTgithub .authauthId // Create an authId for GitHub on https://app.bearer.sh .post'/user/repos', .thenconsole.log .catchconsole.error
Using async/await
:
.authauthId // Create an authId for GitHub on https://app.bearer.sh .post'/user/repos', console.logresponse
Setting the request timeout
By default bearer client times out after 5 seconds. Bearer allows to increase the timeout to up to 30 seconds
// or// import bearer from '@bearer/node' github .invoke'myFunction' .thenconsole.log .catchconsole.error
Learn more on how to use custom functions with Bearer.sh.
Notes
Note 1: we are using axios as the http client. Each .get()
, .post()
, .put()
, ... or .invoke()
returns an Axios Promise.
Note 2: If you are using ExpressJS, have a look at the @bearer/express client