I need help figuring out how to incorporate user input into the header of a post method I am working with. I understand that some kind of binding is necessary, but I'm struggling to implement it in this case. Currently, I have a variable called postData which is hardcoded within the parameter, but I want this parameter to be determined by user input.
Below is the relevant section of my component.ts file:
export class AppComponent {
value = '';
update(value: string) { this.value = value; }
postData ={
name: "apple"
} ;
getResults(postData){
this.http.post<any>('APIUrlhere/issuerRestService/findIssuersBySearchCriteria', postData ).subscribe(data => {
this.searchResult = data;
console.log(this.searchResult)
})
}
}
The following snippet shows the HTML code where I capture user input labeled as "value":
<div>
<label> Enter Company Name </label>
<input #box
(keyup.enter)="update(box.value)"
(blur)="update(box.value)">
<button (click)="getResults(postData)">Search</button>
</div>
Any pointers on how to achieve this would be greatly appreciated. Thank you!