i want to send synchrouns request this nested for loop in angular 6. it all for loop must wait each other response. Please give some example in https://stackblitz.com
protected plateInfo(debug = true) {
for (let i = 0; i < 8; i++) {
for (let k = 0; k < 8; k++) {
if (k % 2 !== 0) {
for (let threshBlock = 21; threshBlock < 31; threshBlock++) {
if (threshBlock % 2 !== 0) {
for (let treshWeight = 5; treshWeight < 19; treshWeight++) {
if (treshWeight % 2 !== 0) {
this.getPLateInfo.getInfoPlate({
qausLast: i,
qausParam: k,
treshBlock: threshBlock,
treshWeight: treshWeight
}).subscribe(_data => {
this.result.push(_data)
_data.input1 = i
_data.input2 = k
})
}
}
}
}
}
}
}
}
Try using await/async
What you need is a
import them from:
More info on concatMap here.
EDIT:
Here is a working stackblitz
Your original "plateInfo" function will make more than 1000 api calls, I hope you know what you are doing.
Anyway, I had to limit the number of items in the array to keep stackblitz site responsive.