The error()
method of the Response
interface returns a new Response
object associated with a network error.
Note: This is mainly relevant to ServiceWorkers; the error method is used to return an error if you so wish it. An error response has its type
set to error
.
Note: An "error" Response
never really gets exposed to script: such a response to a fetch()
would reject the promise.
Syntax
var errorResponse = Response.error();
Parameters
None.
Return value
A Response
object.
Example
TBD (does not yet appear to be supported anywhere).
Specifications
Specification | Status | Comment |
FetchThe definition of 'error()' in that specification. | Living Standard |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
|
Chrome
Full support Yes |
Edge
Full support 16 |
Firefox
Full support Yes |
IE
No support No |
Opera
Full support Yes |
Safari
Full support Yes |
WebView Android
No support No |
Chrome Android
No support No |
Firefox Android
No support No |
Opera Android
No support No |
Safari iOS
No support No |
Samsung Internet Android
No support No |
Legend
- Full support
- Full support
- No support
- No support
- Experimental. Expect behavior to change in the future.'
- Experimental. Expect behavior to change in the future.
See also
Response.error() by Mozilla Contributors is licensed under CC-BY-SA 2.5.