i want to know how i can save the json array from my GET Request on a variable. I am working on a search service and can already search for user but also want to search for Moods (similar to Tweets).
This sends a GET request to the elastic db and requestes MoodTexts(Posts with Text and emoji). If i search for "green", my request finds 4 results in the database and my searchbar in the html shows 4 blank results, but i want to post the found text in those blank fields. Btw Mood is a class with the variable "text".
Component (i think here is the mistake):
mood: Mood[];
getMood() {
const moodText = this.angForm2.value.searchText;
console.log(this.angForm2.value, moodText);
this.searchservice.getElasticPostsResult(moodText).subscribe((data2: any) => {
this.mood = data2.hits.hits;
});
}
HTML:
<div id="textSearch" *ngFor="let moodText of mood">
<br><a id="a2">{{moodText?.text}}</a>
</div>
Console/Request output:
