在Laravel中使用Fetch API删除记录?
- 论坛
- 在Laravel中使用Fetch API删除记录?
7 浏览
在Laravel中使用Fetch API删除记录?
我正在尝试使用fetch api删除laravel中的一条记录,但是我遇到了以下错误:不支持GET方法来访问该路由。支持的方法:DELETE。
路由:
Route::delete('/persona_eliminar/{id}', 'PersonaController@eliminar');
从foreach中获取id的按钮:
Js:
function deletePersona(id) { fetch("/persona_eliminar/" + id, { method: "DELETE", }) .then((res) => res.json()) .then((response) => { console.log(response); });
}