Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Can I remove timeout for just one call? Axios

I created a axios client

const backendClient = axios.create({
  baseURL: window['getConfig']?.url?.backend,
  httpsAgent: new https.Agent({ rejectUnauthorized: false }),
  timeout: window['getConfig']?.timeout || 30000,
});

and I make the every calls with that client in my application. but I want to remove timeout for just one specific call. Is there a way to do it ? U can see my fetch below.

 const loadMessageDetail = () => {
        backendClient.get(getDashboardDataQuery())
            .then((response) => {
               ......
            }).catch(() => {
            ......
        });
    }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This can be done simply by overriding the global timeout setting in the configuration of that specific request. Something like:

const loadMessageDetail = () => {
    backendClient.get(getDashboardDataQuery(), { timeout: 0 }) // <----Notice this config object
        .then((response) => {
           //...
        }).catch(() => {
        //...
    });
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading