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

This commit is contained in:
Sang Nguyen 2022-12-28 00:12:43 +07:00 коммит произвёл GitHub
Родитель cb0688bb52
Коммит f88b22d0c0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 4 добавлений и 4 удалений

Просмотреть файл

@ -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 поставляемый
Просмотреть файл

@ -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;
* ```