Reputation: 3586
I have this code to create a devtools panel in a chrome extension. For learning proupose I want to inspect network requests of a certain website and get the body of them.
chrome.devtools.panels.create('Spotify test', '', '/index.html');
chrome.devtools.network.onRequestFinished.addListener( (request) => {
//console.log(request);
if(request.method === 'GET' && request.response.status === '206' ){
console.log(request);
request.getContent( (content, encoding) => {
console.log(content, encoding);
});
}
});
The problem is that the if(request.method === 'GET' && request.response.status === '206' )
will not be executed, I'm able to log the request object of the callback only if I put it outside the statement. I want to log only requests that are using the GET
method and that have the 206
status code. As I read in the documentation, on the request object I can use the getContent()
method to get the body of the response, is this right? Is there any error in the code that will prevent to the console.log()
to be fired?
NB: I'm using the devtools console that is opened by clicking the inspect menu voice inside the panel I've added.
Upvotes: 1
Views: 2511