mirror of
https://github.com/microsoft/playwright.git
synced 2025-06-26 21:40:17 +00:00
docs: fix wrong waitForResponse example in Node.js (#19701)
This commit is contained in:
parent
cb0688bb52
commit
f88b22d0c0
@ -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;
|
||||
```
|
||||
|
4
packages/playwright-core/types/types.d.ts
vendored
4
packages/playwright-core/types/types.d.ts
vendored
@ -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;
|
||||
* ```
|
||||
|
Loading…
x
Reference in New Issue
Block a user