Hotwire Discussion

Access to the response body on turbo:before-fetch-response

Hi, I would like to access the response body from the event turbo:before-fetch-reseponse. I actually can by accessing the promise but when I do this I get this error:

TypeError: Failed to execute 'text' on 'Response': body stream already read
at FetchResponse.get responseHTML [as responseHTML] (turbo.es2017-esm.js:227)
at FrameController.loadResponse (turbo.es2017-esm.js:2481)
at FrameController.requestSucceededWithResponse (turbo.es2017-esm.js:2530)
at FetchRequest.receive (turbo.es2017-esm.js:352)
at FetchRequest.perform (turbo.es2017-esm.js:335)

Thanks for your help

Can you share the code you used? It seems weird to get a response in a before-fetch-response though