Skip to content

Commit

Permalink
RequestInit / Request() updates
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishwillee committed Oct 8, 2024
1 parent 3cecb3e commit ba742ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
28 changes: 4 additions & 24 deletions files/en-us/web/api/request/request/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,33 +54,13 @@ new Request(input, options)

### Exceptions

<table class="no-markdown">
<thead>
<tr>
<th scope="col">Type</th>
<th scope="col">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>TypeError</code></td>
<td>
Since <a href="/en-US/docs/Mozilla/Firefox/Releases/43">Firefox 43</a>,
<code>Request()</code> will throw a TypeError if the URL has
credentials, such as http://user:[email protected].
</td>
</tr>
</tbody>
</table>
- `TypeError`
- The URL has credentials, such as `http://user:[email protected]` or cannot be parsed.

## Examples

In our [Fetch Request example](https://github.com/mdn/dom-examples/tree/main/fetch/fetch-request) (see [Fetch Request live](https://mdn.github.io/dom-examples/fetch/fetch-request/)) we
create a new `Request` object using the constructor, then fetch it using a
{{domxref("Window/fetch", "fetch()")}} call. Since we are fetching an image, we run
{{domxref("Response.blob")}} on the response to give it the proper MIME type so it will be
handled properly, then create an Object URL of it and display it in an
{{htmlelement("img")}} element.
In our [Fetch Request example](https://github.com/mdn/dom-examples/tree/main/fetch/fetch-request) (see [Fetch Request live](https://mdn.github.io/dom-examples/fetch/fetch-request/)) we create a new `Request` object using the constructor, then fetch it using a {{domxref("Window/fetch", "fetch()")}} call.
Since we are fetching an image, we run {{domxref("Response.blob")}} on the response to give it the proper MIME type so it will be handled properly, then create an Object URL of it and display it in an {{htmlelement("img")}} element.

```js
const myImage = document.querySelector("img");
Expand Down
3 changes: 2 additions & 1 deletion files/en-us/web/api/requestinit/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@ You can also construct a `Request` with a `RequestInit`, and pass the `Request`
- `low`
- : A low priority fetch request relative to other requests of the same type.
- `auto`
- : Automatically determine the priority of the fetch request relative to other requests of the same type.
- : No user preference for the fetch priority.
It is used if no value is set or if an invalid value is set.

Defaults to `auto`.

Expand Down

0 comments on commit ba742ea

Please sign in to comment.