fetch

abstract fun fetch(input: String, init: NetFetchInit = definedExternally): Promise<GlobalResponse>(source)
abstract fun fetch(input: GlobalRequest, init: NetFetchInit = definedExternally): Promise<GlobalResponse>(source)

see Response.

Sends a request, similarly to how fetch() works in the renderer, using Chrome's network stack. This differs from Node's fetch(), which uses Node.js's HTTP stack.

Example:

This method will issue requests from the default session. To send a fetch request from another session, use ses.fetch().

See the MDN documentation for fetch() for more details.

Limitations:

  • net.fetch() does not support the data: or blob: schemes.

  • The value of the integrity option is ignored.

  • The .type and .url values of the returned Response object are incorrect.

By default, requests made with net.fetch can be made to custom protocols as well as file:, and will trigger webRequest handlers if present. When the non-standard bypassCustomProtocolHandlers option is set in RequestInit, custom protocol handlers will not be called for this request. This allows forwarding an intercepted request to the built-in handler. webRequest handlers will still be triggered when bypassing custom protocols.

Note: in the utility process custom protocols are not supported.