How to get post data in chrome extension How to get post data in chrome extension google-chrome google-chrome

How to get post data in chrome extension


I know this was asked so long ago, but in case anyone else comes across this same problem, I found the answer.

You're using the listener onBeforeSendHeaders, when the only listener that supports viewing the POST data is onBeforeRequest. However, you also need to supply an extraInfoSpec of "requestBody" to the third argument of .addListener. An example is below.

/* The Web Request API */const WEB_REQUEST = chrome.webRequest;WEB_REQUEST.onBeforeRequest.addListener(    function(details) {        if(details.method == "POST")            console.log(JSON.stringify(details));    },    {urls: ["<all_urls>"]},    ["blocking", "requestBody"]);