I have this Ajax request function.
export async function fetchAllCoinsPromise() {
const apiCall = await fetch('https://api.coincap.io/v2/assets');
const jsonResult = await apiCall.json();
return jsonResult;
}
I call it like this:
const fetchCoins = () => {
fetchAllCoinsPromise()
.then(res => console.log(111))
.catch(err => {
console.log('err', err);
fetchCoins();
});
};
the reason why I'am doing this recursion is because sometimes I'm getting this strange error: SyntaxError: JSON Parse error: Unexpected identifier "You"] and I thought the async recursion would solve the issue and it does but I am not sure if this is the best solution in case of time complexity. Any suggestions please?
Response Status Codebefore phrase the JSON