I'm trying to switch from request.js
to got.js
. I expect to see the got.js
implementation authenticate similarly to how the request.js
library does. But, instead, I get the following error.
auth no longer supported. Replaced by username and password.
There is no mention of bearer
tokens on the docs page.
So how do I authenticate my request using bearer tokens using got.js
? Or what am I doing wrong?
const request = require('request');
const module.exports = config => {
const options = {
auth: {
bearer: config.secret,
},
};
const result = await new Promise(( resolve, reject, ) => {
request.get( url, options, ( error, response, body, ) => {
...
New code: got.js, throws error
const got = require('got');
module.exports = async config => {
const options = {
auth: {
bearer: config.secret,
},
};
const result = await got(url, options);
...
}