gleam-lang / gleam-lang/fetch

Passing options when sending fetch requests

Open
#4 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
Gleam
Stars
61
Forks
16
Avg merge
5d 20h
Merged PRs (30d)
1

Description

Some time ago we chatted how we could make it possible to pass [request options](https://developer.mozilla.org/en-US/docs/Web/API/fetch#syntax) 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](https://discord.com/channels/768594524158427167/768594524158427170/1115017724658208898). 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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.