From 5dbd69e1a4be65467c2939e05f3ecb49829b4993 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Noel=20Kim=20=28=EA=B9=80=EB=AF=BC=ED=98=81=29?= Date: Wed, 5 Oct 2022 07:05:32 +0900 Subject: [PATCH] chore: type in waitForRequest function description (#9015) --- docs/api/puppeteer.page.waitforrequest.md | 16 +++++----------- src/api/Page.ts | 14 +++++--------- 2 files changed, 10 insertions(+), 20 deletions(-) diff --git a/docs/api/puppeteer.page.waitforrequest.md b/docs/api/puppeteer.page.waitforrequest.md index 3d338a662d8..864bb4928dd 100644 --- a/docs/api/puppeteer.page.waitforrequest.md +++ b/docs/api/puppeteer.page.waitforrequest.md @@ -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 @@ -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(''); -}); -return finalResponse.ok(); +return finalRequest.response()?.ok(); ``` diff --git a/src/api/Page.ts b/src/api/Page.ts index 17f0abbe279..50b973c63a1 100644 --- a/src/api/Page.ts +++ b/src/api/Page.ts @@ -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(''); - * }); - * return finalResponse.ok(); + * return finalRequest.response()?.ok(); * ``` * * @remarks