The integrity read-only property of the Request interface contains the subresource integrity value of the request.
The integrity read-only property of the Request interface contains the subresource integrity value of the request.
The value that was passed as the options.integrity argument when constructing the Request.
If an integrity has not been specified, the property returns ''.
In the following snippet, we create a new request using the Request() constructor (for an image file in the same directory as the script), then reads the request's integrity. Because the request was created without a specific integrity, the property returns an empty string.
js
const myRequest = new Request("flowers.jpg"); console.log(myRequest.integrity); // ""
In the example below, the request was created with a specific integrity value, so the property returns that value. Note that there's no validation of the integrity value; the property returns exactly what was passed in.
js
const myRequest = new Request("flowers.jpg", { integrity: "sha256-abc123", }); console.log(myRequest.integrity); // "sha256-abc123"
| Specification |
|---|
| Fetch Standard # ref-for-dom-request-integrity② |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
integrity |
46 | 14 | 51 | No | 33 | 10.1 | 46 | 46 | 51 | 33 | 10.3 | 5.0 |
© 2005–2023 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Request/integrity