docs: fix wrong waitForResponse example in Node.js (#19701)

This commit is contained in:
Sang Nguyen 2022-12-28 00:12:43 +07:00 committed by GitHub
parent cb0688bb52
commit f88b22d0c0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -4250,12 +4250,12 @@ Returns the matched response. See [waiting for event](../events.md#waiting-for-e
```js
// Start waiting for response before clicking. Note no await.
const responsePromise = page.waitForRequest('https://example.com/resource');
const responsePromise = page.waitForResponse('https://example.com/resource');
await page.getByText('trigger response').click();
const response = await responsePromise;
// Alternative way with a predicate. Note no await.
const responsePromise = page.waitForRequest(response => response.url() === 'https://example.com' && response.status() === 200);
const responsePromise = page.waitForResponse(response => response.url() === 'https://example.com' && response.status() === 200);
await page.getByText('trigger response').click();
const response = await responsePromise;
```

View File

@ -4447,12 +4447,12 @@ export interface Page {
*
* ```js
* // Start waiting for response before clicking. Note no await.
* const responsePromise = page.waitForRequest('https://example.com/resource');
* const responsePromise = page.waitForResponse('https://example.com/resource');
* await page.getByText('trigger response').click();
* const response = await responsePromise;
*
* // Alternative way with a predicate. Note no await.
* const responsePromise = page.waitForRequest(response => response.url() === 'https://example.com' && response.status() === 200);
* const responsePromise = page.waitForResponse(response => response.url() === 'https://example.com' && response.status() === 200);
* await page.getByText('trigger response').click();
* const response = await responsePromise;
* ```