my issue is that data i am getting is in observable so i check if data is undefined and when it is not undefined i put it into doctor object but some of my code use the data before it populate and generate error because value is undefined how can i get the value of response in a variable .
    workingDayFilter = ( d: Date ): boolean => {
    const day = d.getDay();
    let workingDays = this.doctor.workingDays;
    let result: boolean = false;
    for ( let i = 0; i < workingDays.length; i++ ) {
        if ( day == workingDays[i] ) {
            result = true;
        }
    }
    return result;
}
ngOnInit() {
    this.getDoctor();
    console.log( this.doctor );
    this.appointmentForm = this.formBuilder.group( {
        patientId: this.patientId,
        date: this.date,
        timeSlot: this.timeSlot
    } );
}
public getDoctor() {
    this.doctorService.getDoctorPublicInfo().subscribe(( data ) => {
        if ( data != undefined ) {
            this.doctor = data.json();
        }
    } );
}
 
    