0
我收到此錯誤:XMLHttpRequest無法加載http://api.azharcouncil.com/api/Employees/DeleteEmployee?id=11。試圖從表格中刪除員工時,預檢的響應具有無效的HTTP狀態代碼405。預檢的響應具有無效的HTTP狀態代碼405角度4
數據storage.service.ts:
deleteEmployee(employeeId: any){
let url = 'http://api.azharcouncil.com/api/Employees/DeleteEmployee?id='+employeeId;
let headers = new Headers();
headers.append('Content-Type', 'applications/json')
let options = new RequestOptions({ headers: headers });
return this.http.delete(url, options)
.map(resp => resp.json());
}
employees.component.ts:
onDelete(employeeId: any){
this.dataStorageService.deleteEmployee(employeeId).subscribe(
data => {
console.log(data);
return true;
},
error => {
console.log(error.json().error);
console.error("Error delete employes!");
return false;
}
);
console.log(employeeId);
}
**當我在郵遞員嘗試這個網址我可以刪除員工**
headers.append需要2個參數把它給我的錯誤 –
刪除「{}」是錯字錯誤對不起我錯 – Robert
同樣的錯誤發生 –