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

Passing options when sending fetch requests #4

Open
ffigiel opened this issue Sep 17, 2023 · 2 comments
Open

Passing options when sending fetch requests #4

ffigiel opened this issue Sep 17, 2023 · 2 comments

Comments

@ffigiel
Copy link

ffigiel commented Sep 17, 2023

Some time ago we chatted how we could make it possible to pass request options to fetch.send(). I actually forgot about the issue until I hopped back on my toy project this weekend and got stuck 😆 Opening a GH issue this time to keep it visible.

Here's the related discord discussion. We didn't reach any conclusion but it should help jog our memory.

The simplest solution would be to introduce a FetchOptions type that we would pass to a new dedicated function like fetch.send_with_options(request, options).

Another path would be having a new FetchRequest type that wraps the classic gleam/http/request.{Request} with additional fetch-specific fields, such as mode, credentials, etc. We could then provide a builder pipeline to take the request, add options, and send it.

@ffigiel
Copy link
Author

ffigiel commented Sep 17, 2023

I think the builder implementation seems most optimal in terms of future-compatibility. If you agree, I can prepare a little PR so we can focus on how to name things 😉

@lpil
Copy link
Member

lpil commented Sep 18, 2023

A builder sounds good to me! Let's keep the original API intact and have this as a secondary one alongside it

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

No branches or pull requests

2 participants