I have an array of promises and a function I need to call after the promises are complete. However, whenever a single promise fails out of the array, my $q.all(promise) will not launch the callback function.
function searchLibraries(library) {
//console.log(library);
console.log('inside searchlibraries');
var libraryCount = library.length;
for (var i = 0; i < libraryCount; i++) {
//console.log(i,library[i].siteUrl,library[i].listID,library[i].listName)
itemPromise[i] = $().SPServices({
operation: "GetListItems",
webURL: library[i].siteUrl,
listName: library[i].listID,
CAMLViewFields: cViewFieldsLimited,
CAMLQuery: cQueryAllCheckedOutDocuments,
CAMLQueryOptions: cQueryOptions,
cacheXML:true,
completefunc: function (xData,Status){
if($(xData).hasSPError()){
console.log("Error");
console.log("Error Code:" ,$(xData).getSPErrorCode());
console.log("Error Message:" ,$(xData).getSPErrorText());
}
}
})
}
return $q.all(itemPromise).then(parseSearchResult);
}