EducationSansar
10/05/2025, 12:42 AM{ error: 'not ready' }
The response from the last two console logs is:
evalResult Type: object
evalResult: {}
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);