This is the offending code. I've been using callbacks somewhat successfully, but I am new to promises.download is from https://ift.tt/2vhRXEz understanding is that the .then code will be executed if the download is successful, 'exclusive or' the .catch code will be executed if the promise is rejected. Which would imply that a .catch should not run immediately after a .then, but that is exactly what is happening in my output.function getData(callback) { download(downloadUrl).then((xmlData) => { parseData(xmlData, callback); }).catch(retryDownload(callback)); }function retryDownload(callback) { console.log('Error downloading xml data.'); setTimeout(() => { getData(callback); }, 300); }console output is: 1. Sucessful parsing output 2. Error downloading xml data. 1. 2. 1. 2. etc to infinity.Any ideas? Perhaps I misunderstand promises?
Submitted July 30, 2018 at 11:15PM by Palmoftheface
No comments:
Post a Comment