How to execute JavaScript in Camoufox’s main world
# crawlee-js
e
Asking this here if someone can help it here. Somehow this is not working and not even returning:
{ error: 'not ready' }
The response from the last two console logs is: evalResult Type: object evalResult: {}
Copy code
const testData = 'this is test';
const funcStr = `async () => {
  if (!window?.app) return { error: 'not ready' };

  try {
    // this await is important in actual code
    const result = await window.app.someFunc('${testData}');
    // return { data: result };
    return { data: 'test' };
  } catch (err) {
    return { error: 'failed inside page' };
  }
}`;

const evalResult = await page.evaluate('mw:' + funcStr);
console.log('evalResult Type:', typeof evalResult);
console.log('evalResult:', evalResult);