I am running a script with Kameleo and I keep getting this error:
UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection
This is my code:
const { KameleoLocalApiClient, BuilderForCreateProfile } = require('@kameleo/local-api-client');
const puppeteer = require("puppeteer");
(async () => {
const client = new KameleoLocalApiClient();
const baseProfiles = await client.searchBaseProfiles({
deviceType: 'desktop',
browserProduct: 'chrome'
});
// Create a new profile with recommended settings
// for browser fingerprinting protection
const requestBody = BuilderForCreateProfile
.forBaseProfile(baseProfiles[0].id)
.setRecommendedDefaults()
.build();
const profile = await client.createProfile({ body: requestBody });
// Start the browser
await client.startProfile(profile.id);
const browserWSEndpoint = `ws://localhost:5050/puppeteer/$(profile.id)`;
const browser = await puppeteer.connect({browserWSEndpoint, defaultViewport: null});
const page = await browser.newPage();
await page.goto("https://youtube.com");
})();