Last Updated on: (senast uppdaterad på:)
Use .toPromise on the http get. You can then use this returned value in a promise if needed, i.e.:
getIngredient1(id2) { return this.http.get<ILogic10Ingredient[]>( "http://localhost:8080/logic10_base_ingredients/ingredient/"+id2).toPromise(); }
and:
this.getIngredient1(this.ingAvailForUpdate).then ( (data2) => { //alert("ing for: " + this.ingAvailForUpdate + ", " + data2[0].name) } , (err) => alert("err:" + err.message) );
The complete example can be found at https://stackoverflow.com/questions/38781162/how-to-call-an-http-method-without-the-observable-in-angular-2