I'm using promise and was following another example, but when I run the script I am getting an error TypeError: Cannot read property 'then' of undefined
. My code appears as the following:
var completedLinks = ["http://www.example.com/1","http://www.example.com/2","http://www.example.com/3"]
function fetchSiteDetails(arr){
arr.reduce(function(promise, email) {
console.log(email)
}, Promise.resolve());
}
fetchSiteDetails(completedLinks).then(function() {
console.log('all done');
});
I guess that fetchSiteDetails
isn't valid to use then
on, but I'm not sure why?