How to fetch data from the database and set the data from the database into an input box
Following is a piece of my code
get service
getStudentAddress() {
const id = sessionStorage.getItem('userId');
return this.http.get('http://localhost:8080' + '/student/' + id);
}
The getStudentAddress()
that will return an array of the student data something like this
in my component, how can I get the data and put it on an input box that will display the data automatically when the page is open
ngOnInit() {
// Here should the display is from the database by using setValue or patchValue
this.studentForm.setValue({
s_pNumber: '1234',
s_address: '123',
s_address2: '123',
s_pCode: '123',
s_city: '123',
s_state: '123',
s_country: '123'
});