I'm attempting to save records to a database two table that includes a foreign key using Spring-Boot and angular but I don't know how to figure it :
by the way this is my entities classes with relation inheritance :
Entitie User
Entitie Patient
And For consuming data API I use this post method for register :
Register Post Controller Api
In Angular Projet I have Put This Register Method on services for user :
const API_URL = 'http://localhost:8080/api/user/';
register(user: User): Observable<any> {
return this.http.post(API_URL + 'registration', JSON.stringify(user),
{headers: {'Content-Type': 'application/json; charset=UTF-8'}});
}
And For Register Component I Use this :
register() {
this.userService.register(this.user).subscribe(data => {
this.router.navigate(['/login']);
}, err => {
this.errorMessage = 'Username is already exist.';
}); }
so in this case I want when it files all form input and click on insert it will insert data for both table user and patient at the same.
any help can be appreciated thank uu
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…