docs(api.md): fix exposeFunction example (#1900)

This commit is contained in:
Andrey Lushnikov 2018-01-25 14:50:42 -08:00 committed by GitHub
parent 189deb84c0
commit ddc59b2472
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) => {