Skip to content

Commit

Permalink
chore: type in waitForRequest function description (#9015)
Browse files Browse the repository at this point in the history
  • Loading branch information
Noel Kim (김민혁) committed Oct 4, 2022
1 parent c0c7878 commit 5dbd69e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
16 changes: 5 additions & 11 deletions docs/api/puppeteer.page.waitforrequest.md
Expand Up @@ -28,7 +28,7 @@ class Page {

Promise<[HTTPRequest](./puppeteer.httprequest.md)>

Promise which resolves to the matched response
Promise which resolves to the matched request

## Remarks

Expand All @@ -39,15 +39,9 @@ Optional Waiting Parameters have:
## Example

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

0 comments on commit 5dbd69e

Please sign in to comment.