'Disable axios request logging

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



Solution 1:[1]

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

Solution 2:[2]

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 comalex3
Solution 2 aemonge