Skip to content

[Question]: how can I access async response's body in the predicate? #1545

@Yxue-1906

Description

@Yxue-1906

Your question

I can simply do this with sync api but I have no idea how to with async api;
I've tried code like:

def check(response):
  body_text = response.text()
  # check if it is the response I need

async def foo():
  page = await browser.new_page()
  async with page.expect_response(url_or_predicate=check) as res:
    #other job

but only got error said coroutine returned by response.text() needs await;
if I change check to async function I got another error said check needs await.
what is the correct way accessing response's body with async api?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions