How to handle two parallel web service calls in Angular 2

How to handle two parallel web service calls in Angular 2

I have two parallel web service calls. Sometimes my first service call calling first and sometimes second one. My second service have a function, but that function requires my first service call data.

I have two parallel web service calls. Sometimes my first service call calling first and sometimes second one. My second service have a function, but that function requires my first service call data.

I tried do an if statement, like if firstData exist then call the other service. But didn't work

this.service.getFirstData(reqParams).then((data: any) => {
                        if (data.response) {
                            this.firstData = data.response;
                        }
                    }).catch(err => {
                            console.log(err);
                    });
this.service.getSecondData(data.user, this.itemselected).then((data: any) => {
                            if (data) {
                                this.listData = data.response.list;
                                this.calculateData();
                            }
                        }).catch((err: any) => {
                                console.log(err)
                        });

The service are asynchronous. How can I handle this weird behavior? Thanks in advance

Angular 9 Tutorial: Learn to Build a CRUD Angular App Quickly

What's new in Bootstrap 5 and when Bootstrap 5 release date?

Brave, Chrome, Firefox, Opera or Edge: Which is Better and Faster?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

An Angular Roadmap — The Past, Present, and Future of Angular

✅Interested in being an Angular developer in 2019? ... blog post it's most likely that you've written some code in javaScript in the past.