Is it possible to clear the network tab activity programmatically in JS

I’ve started in full-stack dev recently, and these days I use XHR to fetch any sensitive data from my server.

As we know, there is a network tab in many browsers, which keeps track of XHR request and response. But, since POST data’s are sensitive, I want to hide them on the client-side. I already know how to clear the console, but is it possible to clear the network tab too?

I’m asking this bcoz there is a button to clear the network tab manually, can it be done in JS somehow? If not, then are there any efficient alternatives to XHR?

I don’t think so. Here are a few alternatives
1(Impratical). There’s javascript library to detect devtools. Once the library detects devtools being opened or open, you can make it redirect to a homepage or some other page you don’t care about.
2. Encrypt your data before it is being sent to the client, then decrypt it in javascript when it’s being received.
An alternative to XHR is fetch which to be honest I haven’t tried out yet but I heard it’s supposed to be easier to use.

1 Like

Yes, as @javaarchive said, an efficient alternative to XHR is the Fetch API.

To get started: Using Fetch | CSS-Tricks - CSS-Tricks
The whole Fetch API documentation: Fetch API - Web APIs | MDN

BTW, by sensitive info. I’m talking about otp, and I’m mailing it to client’s mail by OAuth2 api. After that, I get the otp on client-side in xhr.responseText, in order to verify it.

@javaarchive, I guess encryption would do the trick!

@khalby786, I just tried fetch, and it is also showing up the response data in net. By “alternative”, I actually meant a thing that can hide the responses. But, now I think, that’s impossible…

1 Like