Я создаю службу h RestApi через spring-boot, при вызове этого API через ionic выдается ошибка DELETE http://localhost:8080/patientsundefined 404 (), вот мой код: ОШИБКА HttpErrorResponse {headers: HttpHeaders, status:404, текст состояния: «OK», URL: «http://localhost:8080/patientsundefined", ok: false…}
#ts
deletePatient(Patient_add:Patient){
this.databasedata.deletePatient(Patient_add).subscribe(
(data:any)=>{
if(data.affectedRows==1){
let mes=this._toast.create({
message:'Task Deleted Successfully',
duration:2000,
position:'bottom'
});
this.AllPatient.splice(this.AllPatient.indexOf(Patient_add),1);
mes.present();
}
else{
let mes=this._toast.create({
message:'Error in deleting task',
duration:2000,
position:'bottom'
});
mes.present();
}
}
,)}
#.html
<ion-content padding>
<ion-list inset>
<ion-input type="hidden" placeholder="id" autofocus="" [(ngModel)]="id" ></ion-input>
<ion-input placeholder="Write here your name" [(ngModel)]="name" ></ion-input>
<ion-input placeholder="Write here your doctor name" [(ngModel)]="doctor_name" ></ion-input>
<ion-input placeholder="Write here your Hosptial or clinic name" [(ngModel)]="hospital_clinic" ></ion-input>
<ion-input placeholder="Write date or your prescription?" [(ngModel)]="date" ></ion-input>
<ion-buttons>
<button (click)= "addPatient()"> ADD</button>
</ion-buttons>
<ion-item *ngFor="let AP of AllPatient" >
<ion-label [ngClass]="{'donestatus': AP.Status=='done','pendingstatus':AP.Status=='pending'}" >{{AP.name}} {{AP.doctor_name}} {{AP.hospital_clinic}} {{AP.date}}</ion-label>
<ion-icon item-right (click)="deletePatient(AP)" ios="ios-trash" md="md-trash"></ion-icon>
<ion-icon item-right (click)="updatePatient(AP)" ios="ios-color-wand" md="md-color-wand"></ion-icon>
<!--<ion-icon name="trash" ios="ios-trash" md="md-trash"></ion-icon>-->
</ion-item>
</ion-list>
</ion-content>
#provider.ts
deletePatient(item:Patient){
return this.http.delete(this.url+item.Id, httpOptions)
}
#.Controller(Spring-boot)
@RequestMapping(value = "patients/{id}", method = {RequestMethod.DELETE})
public ResponseEntity<Void> delete(@PathVariable("id") int id) {
try {
service.deletePatient(id);
return new ResponseEntity<Void>(HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<Void>(HttpStatus.BAD_REQUEST);
}
}