I'm having trouble with the last line of code in my program and I need some help figuring out how to fix it. Specifically, I know that the second "then" statement needs to return resolve() but I'm not sure how to go about implementing this. Any tips or suggestions would be greatly appreciated!
let getNumber = new Promise((resolve) => {
//API call
EthereumNote.getAmountOfMyNotes(function(error, result) {
if (!error) {
let AmountOfMyNotes = Number(result)
resolve(AmountOfMyNotes)
console.log(result)
} else
console.error(error)
})
}).then(result => {
return new Promise((resolve) => {
for (let i = 0, p = Promise.resolve(); i < result; i++) {
p = p.then(_ => new Promise(resolve => {
//Another API call
EthereumNote.getMyNote(i, function(error, result) {
if (!error) {
let text = String(result[0])
let noteID = Number(result[1])
console.log(text)
console.log(noteID)
resolve()
} else
console.error(error)
})
}));
}
})
}).then(() => console.log('Hi!')) // Having trouble with this part