-1

i get null in the subscribe statemaent, the Api returns the correct data, but in angular its accepted as null. what should be the problem? here is my subscribe in ts:

this.service.getFlightId( this.addFlightForm.controls["date"].value, this.addFlightForm.controls["time"].value,
this.originId,
this.destinationId,
this.addFlightForm.controls["flightNum"].value)
   .subscribe(data=>{
  this.flight=data;
}, err=>{
  this.noFlightId=true;
}); 

and this is my serviece:

getFlightId(date:Date,time:Time,originId:number,destinationId:number,flightNum:number):Observable<Flight>{
        return this._http.get<Flight>("/api/flight/"+date+"/"+time+"/"+originId+"/"+destinationId+"/"+flightNum);
    }
Charlie
  • 47
  • 1
  • 1
  • 6
  • Where are you accessing the variable `this.flight` in the component? Please show more code. – ruth May 31 '20 at 10:21

1 Answers1

0

As your configurationUrl = "/api/flight/"+date+"/"+time+"/"+originId+"/"+destinationId+"/"+flightNum`. I hope you cannot have any api call with exact parmas like

/flight/23-06-2020/12:00/originId/DestinationId/filghtnumber

can you check in your backend if you have an API request like this /api/flight/23-06-2020/12:00/Austria/germany/F121.

Generally we make http call like below,

this.httpClient.get<any>(url, { params: x });

Or may be this Link or stakeoverflow link can help you.

Mahaveer
  • 1
  • 2