chore: type in waitForRequest function description (#9015)

This commit is contained in:
Noel Kim (김민혁) 2022-10-05 07:05:32 +09:00 committed by GitHub
parent c0c7878adc
commit 5dbd69e1a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 20 deletions

View File

@ -28,7 +28,7 @@ class Page {
Promise<[HTTPRequest](./puppeteer.httprequest.md)> Promise<[HTTPRequest](./puppeteer.httprequest.md)>
Promise which resolves to the matched response Promise which resolves to the matched request
## Remarks ## Remarks
@ -39,15 +39,9 @@ Optional Waiting Parameters have:
## Example ## Example
```ts ```ts
const firstResponse = await page.waitForResponse( const firstRequest = await page.waitForRequest('https://example.com/resource');
'https://example.com/resource' const finalRequest = await page.waitForRequest(
request => request.url() === 'https://example.com'
); );
const finalResponse = await page.waitForResponse( return finalRequest.response()?.ok();
response =>
response.url() === 'https://example.com' && response.status() === 200
);
const finalResponse = await page.waitForResponse(async response => {
return (await response.text()).includes('<html>');
});
return finalResponse.ok();
``` ```

View File

@ -1478,21 +1478,17 @@ export class Page extends EventEmitter {
/** /**
* @param urlOrPredicate - A URL or predicate to wait for * @param urlOrPredicate - A URL or predicate to wait for
* @param options - Optional waiting parameters * @param options - Optional waiting parameters
* @returns Promise which resolves to the matched response * @returns Promise which resolves to the matched request
* @example * @example
* *
* ```ts * ```ts
* const firstResponse = await page.waitForResponse( * const firstRequest = await page.waitForRequest(
* 'https://example.com/resource' * 'https://example.com/resource'
* ); * );
* const finalResponse = await page.waitForResponse( * const finalRequest = await page.waitForRequest(
* response => * request => request.url() === 'https://example.com'
* response.url() === 'https://example.com' && response.status() === 200
* ); * );
* const finalResponse = await page.waitForResponse(async response => { * return finalRequest.response()?.ok();
* return (await response.text()).includes('<html>');
* });
* return finalResponse.ok();
* ``` * ```
* *
* @remarks * @remarks