I'm trying to delete item from the list but, i think my endpoint is incorrect.
My enpoint is like: http://localhost:3001/notes/360e88a6-6dde-4971-b32c-802963013c29 and id is genereated by uuid.
JSON structure is like { content: "seoul", phone: "111-222-333", date: "11.4.2022", important: false, id: "4426ad6e-e22f-4a83-859c-a3436bf06959" }, { content: "daegu", phone: "555-666-777", date: "11.4.2022", important: true, id: "03c08131-4866-40a3-b44c-e161c163e467" }
Functionality
const baseUrl = 'http://localhost:3001/notes'
const delete_person = (id) => {
return axios.delete(`${baseUrl}/${id}`)
}
function handleDelete(id) {
const newList = todos.filter((item) => item.id !== id);
axios.delete().then(response => {
setContacts(contacts.concat(response.data))
setNumberInput('');
});
return setTodos(newList);
}
return (
<div className="App">
<header className="App-header">
<ol>
{notes.map((todo, index) => {
return (
<li key={index}>
<span>Name: {todo.content}, </span>
<span>Phone {todo.phone}, </span>
<span>Date {todo.date}, </span>
<button type="button" onClick={handleDelete}>
Remove
</button>
</li>
)
})}
</ol>```