I have the following function which essentially calls three other promise based functions. The promises all seem to be woking, however I can't get the function to return the tableData array.
Any pointers would be very helpful.
function getALLBooks() {
tableData = []
getAPIKey(creds)
.then(apikey => {
// console.log(apikey)
getBooks(apikey).then(books => {
// console.log(books)
books.forEach(function (value) {
// console.log(value.Guid);
getBook(apikey, value.Guid).then(book => {
// console.log(apikey)
// console.log(book)
console.log(book.Name)
tableData.push({
"name": book.Name
})
})
});
return tableData
})
})
.catch(error => {
console.log(error)
})
}
getALLBooks()