docs.rodeo

MDN Web Docs mirror

devtools.network.onRequestFinished

{{AddonSidebar}} 

Fired when a network request has finished and its details are available to the extension.

The request is given as a HAR entry object, which is also given an asynchronous getContent() method that gets the response body content.

Note that although your extension can add a listener at any time, it will only start firing after the user has activated the browser’s network panel at least once.

Syntax

browser.devtools.network.onRequestFinished.addListener(listener)
browser.devtools.network.onRequestFinished.removeListener(listener)
browser.devtools.network.onRequestFinished.hasListener(listener)

Events have three functions:

addListener syntax

Parameters

Browser compatibility

{{Compat}} 

Examples

Add a listener that logs the server IP address and response body for every network request.

function handleRequestFinished(request) {
  console.log("Server IP: ", request.serverIPAddress);
  request.getContent().then(([content, mimeType]) => {
    console.log("Content: ", content);
    console.log("MIME type: ", mimeType);
  });
}

browser.devtools.network.onRequestFinished.addListener(handleRequestFinished);

{{WebExtExamples}} 

[!NOTE] This API is based on Chromium’s chrome.devtools API.

In this article

View on MDN