I'm looping over this url /api?id=1&page=
every time requesting a different page until i get the result i want.
I can't figure out how and why i can't stop the loop from within the request.
async something() {
let results = []
for (let i = 0;i < 999;i++) {
await rp('/api?id=1page='+i).then(string => {
results.push(string)
if(results === 'THE END') {
// break here
}
})
}
Promise.all(results).then(res => {
// do something
})
}