I currently handle my promises by calling an async function and chaining it with .then(). But I wish there was a more readable way.
My current feasible method is:
const apiCall = async() => { const response = await axios.get("URL"); return response; } apiCall().then(res => { console.log(res.data); });
I want my code to look like:
const apiCall = () => { const response = axios.get("URL); return response; } const fetchData = async() => { const response = await apiCall(); return response.data; } console.log(fetchData());
how