extension.sendRequest()
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.
[!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
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- :
string. The extension ID of the extension you want to connect to. If omitted, default is your own extension. request- :
any. responseCallback- :
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
[!NOTE] This API is based on Chromium's
chrome.extensionAPI. This documentation is derived fromextension.jsonin the Chromium code.