extension.sendRequest()

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

Warning: This method has been deprecated. Use runtime.sendMessage instead.

Sends a request to other listeners within the extension. Similar to runtime.connect, but only sends a request with an optional response. The extension.onRequest event fires in each page of the extension.

Syntax

js
chrome.extension.sendRequest(
  extensionId,             // optional string
  request,                 // any
  (response) => {/* … */}  // optional function
)

This API is also available as browser.extension.sendRequest() in a version that returns a promise.

Parameters

extensionId Optional

string. The extension ID of the extension you want to connect to. If omitted, default is your own extension.

request

any.

responseCallback Optional

function. The function is passed these arguments:

response

any. The JSON response object sent by the handler of the request. If an error occurs while connecting to the extension, the callback will be called with no arguments and runtime.lastError will be set to the error message.

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Firefox for Android
Safari on iOS
sendRequest
Chrome – Full support
Chrome 5 (Release date: 2010-05-25)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – No support
Firefox
footnote No support
Opera – No support
Opera
footnote No support
Safari – No support
Safari
footnote No support
Firefox for Android – No support
Firefox for Android
footnote No support
Safari on iOS – No support
Safari on iOS
footnote No support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
No support
No support

Note: This API is based on Chromium's chrome.extension API. This documentation is derived from extension.json in the Chromium code.