const deleteHandler = async () => {
await axios.delete('(http://localhost:5000/users/)' + editId).then((res) => {
const deleteUser = data.filter((obj) => obj._id !== editId);
handleGet();
setData(deleteUser);
setEditId('');
});
};
需要接受API id来删除API。
你错误的括号:
await axios.delete('(http://localhost:5000/users/)' + editId)
应:
await axios.delete('http://localhost:5000/users/' + editId)
也可以和反号一起使用:
Should be:
await axios.delete(`http://localhost:5000/users/${editId}`)
你可能想在请求体中传递id:
const res = await axios.delete('http://localhost:5000/users', { data: { id: editId } });