mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
docs(api.md): fix exposeFunction example (#1900)
This commit is contained in:
parent
189deb84c0
commit
ddc59b2472
@ -806,7 +806,7 @@ const crypto = require('crypto');
|
||||
|
||||
puppeteer.launch().then(async browser => {
|
||||
const page = await browser.newPage();
|
||||
page.on('console', msg => console.log(msg.text));
|
||||
page.on('console', msg => console.log(msg.text()));
|
||||
await page.exposeFunction('md5', text =>
|
||||
crypto.createHash('md5').update(text).digest('hex')
|
||||
);
|
||||
@ -828,7 +828,7 @@ const fs = require('fs');
|
||||
|
||||
puppeteer.launch().then(async browser => {
|
||||
const page = await browser.newPage();
|
||||
page.on('console', msg => console.log(msg.text));
|
||||
page.on('console', msg => console.log(msg.text()));
|
||||
await page.exposeFunction('readfile', async filePath => {
|
||||
return new Promise((resolve, reject) => {
|
||||
fs.readFile(filePath, 'utf8', (err, text) => {
|
||||
|
Loading…
Reference in New Issue
Block a user