rails / request.js

MIT License
389 stars 28 forks source link

Use window.Turbo.fetch if available for turbo-stream requests #74

Closed brendon closed 2 weeks ago

brendon commented 2 weeks ago

Checks for window.Turbo and if the responseKind is turbo-stream and if both are true then request.js will use window.Turbo.fetch in order to append X-Turbo-Request-Id to the request headers.

The tests don't actually bring in Turbo just as the existing tests don't.

window.Turbo.fetch as at time of writing: https://github.com/hotwired/turbo/blob/4d65288e913d5a5428e290781313c7909763b133/src/http/fetch.js

Closes: https://github.com/rails/request.js/issues/73

brendon commented 2 weeks ago

Let me know if you need any further testing done, or have any concerns with this change. I've been using it in development and it's working really well. Much cleaner than fake-clicking hidden submit buttons ;)

brendon commented 1 week ago

Hi @marcelolx, just wondering if you'd be able to make a new release with this change in it? :)

marcelolx commented 1 week ago

@brendon I will once we get to merge https://github.com/rails/request.js/pull/72 as well

marcelolx commented 1 week ago

@brendon Done

brendon commented 1 week ago

Thanks @marcelolx :D