[Fixed] Wait for response in angular subscriber


I have seen multiple posts with the same title but none of them is what I need for my use case.
I have an array of items, item property can have (‘serials’,’macs’,’null’) I have to call a different API end point for each one
and for example inside ‘model’ there are an array of models
which also need to be sent one by one. I know it’s not the best way to deal with this but it’s a long story and I’m not responsible for this mess of a design .
the service code :

  createDevice(data: Device) {
    return this.http.post('somewhere', data, {
      headers: this.httpHeader,

component code:


  //create it

 else if(item.macs){

  //create it



  // create it 


the problem is there are other properties which will get affected by this and I don’t want them to.
is there a way to do this.


you can use toPromise() to convert it into a promise and use await.


Leave a Reply

(*) Required, Your email will not be published