Использую библиотеку pupeteer.js и axios для запросов
const puppeteer = require('puppeteer');
const axios = require('axios');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const api = 'api';
await page.goto(api);
const headers = await page.evaluate(() => {
return {
Authorization: '*',
login: 'login',
password: 'password',
};
});
const data = await axios.get(api, { headers });
console.log(data.data);
await browser.close();
})();
const auth = "login:password";
const encodedAuth = Buffer.from(auth).toString("base64");
const config = {
headers: {
Authorization: `Basic ${encodedAuth}`,
},
timeout: 120000,
};
const config = {
headers: {
Authorization: "Bearer *",
login: "login",
password: "password",
},
timeout: 120000,
};
const puppeteer = require('puppeteer');
const axios = require('axios');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
const api = 'api';
await page.goto(api);
const headers = await page.evaluate(() => {
return {
Authorization: 'Bearer *',
login: 'login',
password: 'password',
};
});
const data = await axios.get(api, { headers });
console.log(data.data);
await browser.close();
})();