Overriding Request and Response built-ins
KonnorRogers opened this issue · 3 comments
Hi I just noticed this neat little library and couldnt help but notice it clashes with the built-in Request and Response classes.
https://developer.mozilla.org/en-US/docs/Web/API/Response
https://developer.mozilla.org/en-US/docs/Web/API/Request
Was this intended? Or was this an accidental clash?
FWIW, Turbo uses FetchRequest and FetchResponse and was curious if we could use a similar convention here or add some other kind of prefix to allow both Classes to coexist in harmony.
@ParamagicDev Hi, originaly this was extracted from hey.com, so I'm not sure if it is intended. But I agree with using a similar convention that Turbo uses or some prefix to allow both classes coexist.
I've to take a look if turbo exports FetchRequest and FetchResponse, if not maybe we could use the same names, what do you think?
https://github.com/hotwired/turbo/blob/main/src/http/fetch_request.ts
https://github.com/hotwired/turbo/blob/main/src/http/fetch_response.ts
Heres the Turbo FetchRequest / FetchResponse classes so you dont have to go digging.
I have no issues with using FetchRequest / FetchResponse personally. Its what I shamelessly did on my UJS refactor I have that uses Typescript + Fetch with Rails. I just wanted to make sure it was well documented that this overrides built-ins which people may not be aware of!
I fully support any decision you feel is appropriate!
Thank you for the feedback @ParamagicDev, I renamed the classes to FetchRequest/FetchResponse following the same conventions that Turbo follows