I have Angular 5 app with the following service call:
let isExist: boolean;
this.http.get<Boolean>(`${this.baseUrl}/Trips/TripExist`, {
headers: new HttpHeaders({ 'Accept': 'text/plain', 'Content-Type': 'text/plain' }),
params: {id: id, name: name},
observe: 'response'
}).subscribe(
data => { isExist = data.body;
console.log(data);
},
err => console. error(err)
);
if (isExist == true) {
Console....
}
The rest api is as follow:
@GET
@Produces("text/plain")
@Path("TripExist")
public boolean isTripExist(@QueryParam("id") String id,
@QueryParam("name") String name) {
return tripDao.isTripExist(name, id);
}
I'm getting in the console an HttpResponse with the boolean value in the body but I don't know how to fetch the value and assign it to a boolean value.