Disable axios request logging

Viewed 1042

Axios request output to console and log files some debug info. Any idea how to make axios silent?

enter image description here

For logging I'm using winston, tried to disable at all logging, but still see this output data.

PS: bearer token is out dated

2 Answers

In my .env file I have line DEBUG = * If I remove that, don't see any more logs.

Basically due to security issues you would have to tolerate:

[2022-03-23T12:06:17.789Z]  "GET /" "axios/0.26.1"

You would also need to treat the promise, either with .catch, await-to-js or wrap axios in a try block

try block

let data;

try {
  data = await axios.get('http://example.com');
} catch (e) {
  e = !e; // do nothing with the error
}

await-to-js

    const { to } = require('await-to-js');
    let E;
    
    function error(msg) {
        console.error(msg);
        
    }
    
    [E, html.to] = await to(axios.get('http://example.com'));
    if (E) E=!E; // do nothing with the error

Related