#get user by id
5 messages · Page 1 of 1 (latest)
reactive-form.html
class="btn btn-success"
(click)="onGetById()">
Get user by ID
</button>
reactive-form.component.ts
const uID = prompt('Enter the ID of the user you wish to know about')
id = Number(uID);
console.log(`here`);
console.log(id);
this.userService.getById(id)
} ```
----------------------------------------------
service.ts
``` getById(id: number) {
return this.http.post('http://localhost:3000/get/get/',id)
.subscribe((res) => {
console.log(res);
})
}
and here i have the form in reactive-form.component.ts
this.userForm = this.fb.group({
Name: [null, [Validators.required, Validators.maxLength(16)]],
Username: [null, [Validators.required, Validators.maxLength(16)]],
Email: [null, [Validators.required, Validators.email]],
UserPassword: [null, [Validators.required, Validators.minLength(8)]],
Gender: [null, Validators.required],
Country: [null, Validators.required],
// postalCode: [null,Validators.maxLength(5)],
Languages: [null, [Validators.required]],
Notes: [null]
})
} ```
idk what i'm supposed to send here
(click)="onGetById()"
onGetById should not have any parameter: you don't do anything with the parameter, other than overwriting it with what the prompt returns.
oh right