Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Unable to obtain response data #481

Open
youfak opened this issue Sep 2, 2024 · 1 comment
Open

[Bug]: Unable to obtain response data #481

youfak opened this issue Sep 2, 2024 · 1 comment
Labels
p2-bug Something isn't working

Comments

@youfak
Copy link

youfak commented Sep 2, 2024

func handleResponse(res playwright.Response) {
	statusCode := res.Status()
	url := res.URL()
	fmt.Printf("Response URL: %s\n", url)
	fmt.Printf("Status Code: %d\n", statusCode)

	var data jsonResponse
	body, err := res.Body()
	if err != nil {
		fmt.Println("Error getting body:", err)
		return
	}
	err = utils.ConvertStruct(body, &data)
	if err != nil {
		fmt.Println("Error parsing JSON:", err)
		return
	}
	fmt.Println("Parsed JSON Data:", data)
}

page.OnResponse(handleResponse)

Executing until the step of reading the body will enter a false death state, and the subsequent code cannot be executed

@youfak youfak added the p2-bug Something isn't working label Sep 2, 2024
@canstand
Copy link
Collaborator

canstand commented Sep 4, 2024

Handle it in another gorountine

func handleResponse(res playwright.Response) {
  go func() {
    ...
  }()
}
}

or refer to this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants