Skip to content
Advertisement

How to define time out to API petition using axios reactjs

I am trying to set timeout to API petition in case i get some error using get, then Loader keeps running for at least 3 seconds to finally show a text sayd “no data or API connection/petition failed”.

I have Dashboard.jsx that works perfectly if theres not error for url, server API fallen, etc. To simulate an error i just changed url and I turned off the server but i get TypeError: paciente.map is not a function and Loader dies instantly.

I tried setting timeout: 3000 in axios but get anything

JavaScript

Advertisement

Answer

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement