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

body stream already read: useFetch<LoginResponse>(url).get().json().onFetchResponse #3130

Closed
4 tasks done
idefixcert opened this issue May 31, 2023 · 1 comment
Closed
4 tasks done
Labels
enhancement New feature or request

Comments

@idefixcert
Copy link

Clear and concise description of the problem

I am not sure if this is a bug or not, but I encounter the following Problem:

  useFetch<LoginResponse>(`url`).get().onFetchResponse(async (data: Response) => {
    const gotUser = await data.json()
  })

Uncaught (in promise) TypeError: Failed to execute 'json' on 'Response': body stream already read

And also:

useFetch<LoginResponse>(`url`).get().json().onFetchResponse(async (data: Response) => {
    const gotUser = await data.json()
  })

the same.

I am wondering if it should not be possible to just directly use onFetchResponse after the get or set resource and also not sure when the data is already read.

The only way it worked:

const {data, onFetchResponse} = useFetch<LoginResponse>(`url`).get()

  onFetchResponse(async (response) => {
    //const gotUser: LoginResponse = await response.json()
    const gotUser: LoginResponse = <LoginResponse>unref(data)
  })

Suggested solution

Not sure if that ist an issue

Alternative

No response

Additional context

No response

Validations

@idefixcert idefixcert added the enhancement New feature or request label May 31, 2023
@stale
Copy link

stale bot commented Jul 30, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant