score:3

put a [] after the function in useeffect like this:

useeffect(() => {
    covidapi.getdata({url:'/totals'})
    .then((response) => {
        settotal(response.data[0]);
        setmessage('');
        console.log(response.data);
    })
    .catch((error) => {
        setmessage("no data found");
        console.log(error);
    })
}, []);

this will call the api only once.


Related Query

More Query from same tag