I'm trying to load axios in chromium using puppeteer, the code is as follows:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({headless:false})
const page = await browser.newPage()
await page.goto('https://httpbin.org/get')
await page.evaluate(async () => {
var script = document.createElement('script');
script.setAttribute('src','https://unpkg.com/[email protected]/dist/axios.min.js');
document.head.appendChild(script);
var r = await axios.get('https://httpbin.org/get')
console.log(r)
})
})()
But when I try to execute axios.get it returns Evaluation failed: ReferenceError: axios is not defined. What's the issue here?