I am using useEffect to make api call before the page is loading. But when I log the result, I see that it makes 2 console.log()s. How can I make this 1?
useEffect(() => {
// Function to make the Axios request
const fetchData = async () => {
try {
//console.log("fetching data\n");
await axios
.get(
"someurl.com/test",
{}
)
.then((res) => {
console.log("data: ", res.data);
});
} catch (err) {
console.log("Error: ", err);
}
};
fetchData();
},[]);