whatwg / whatwg/fetch

Feed a Response to existing APIs

Open
#49 20 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

addition/proposal needs implementer interest topic: api
Dominant language
HTML
Stars
2.3k
Forks
403
Avg merge
21h 16m
Merged PRs (30d)
4

Description

If you manage all network activity yourself you still need a way to inject the results into existing APIs that consume them. There's two approaches here that I know of:

<img>.srcObject = responseInstance
<img>.src = convertResponseToURL(responseInstance)

The first is more elegant, the second invokes Fetch twice (but the convertResponseToURL() URL should be a way shorter trip). If we go with the second, which scales better due to the many APIs in existence, we need to avoid the flaws from blob URLs and make sure the URL can be used only once and consumes the underlying stream (you cannot use responseInstance again, if you wanted to do that you'd have to clone it first).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the Fetch Standard's existing Response, stream, and URL behavior referenced in the issue. Compare the srcObject and convertResponseToURL approaches, including one-time URL use and cloning; done requires an agreed behavior for feeding a Response into existing APIs.

Written by the indexing model from the issue text.

Assessment

Tech stack
html
Domain
api, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.