Quiero agregar un usuario-amigo, este es mi código de angular.
import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class ListUserService {
constructor(public http: HttpClient) {
this.http.get(`http://localhost:8080/user/getUsers/`)
.subscribe(response => {
console.log(response);
});
}
getUsers() {
const url = 'http://localhost:8080/user/getUsers/';
return this.http.get<Object[]>(url);
}
addFriend(user) {
console.log('EEEEEE');
const url = 'http://localhost:8080/meet/friend';
return this.http.post(url, {idOwner: user.id, userId: user.id});
}
}
Pero solo obtengo error 400 ¿cual es el problema?
Este es mi endpoint.
@RequestMapping(
value = "/friend/{idUser}/owner/{idOwner}",
method = RequestMethod.POST
)
public ResponseEntity<Meet> friend( @PathVariable Long idUser,@PathVariable Long idOwner) {
log.info("PUSEN " +idOwner+" "+idUser);
return new ResponseEntity<Meet>(meetService.createMeetWithFriend(idOwner, idUser), HttpStatus.OK);
}