Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const makeGetRequest = function (token: string, options: any, cb: EVCallback) {
- const req = https.get(Object.assign({}, options, {
- protocol: 'https:',
- hostname: 'registry-1.docker.io',
- path: '/v2/ubuntu/manifests/latest'
- }),
- function (res) {
- res.once('error', cb);
- res.setEncoding('utf8');
- let data = '';
- res.on('data', function (d) {
- data += d;
- });
- res.once('end', function () {
- try {
- const r = JSON.parse(data) as any;
- return cb(null, r);
- }
- catch (err) {
- return cb(err);
- }
- });
- });
- req.write(`Authorization: Bearer ${token}`);
- req.end();
- };
- req.setHeader('Authorization',`Bearer ${token}`);
Add Comment
Please, Sign In to add comment