score:1

Accepted answer

in your deletemeal action, you have to put the id in the url dynamically with template strings,

await fetch("/api/meals/:id/" + id

1) it's equal to /api/meals/:id/id but according to your backend it should be /api/meals/:id
2) and you have to put the whole url like http://localhost:5000/api/meals/${id} cause if you don't put the base, it will do a request on the port of your client so 3000

///////

so instead of :

export const deletemeal = (id) => async (dispatch) => {
  await fetch("/api/meals/:id/" + id, {
    method: "delete",
  });
  dispatch({
    type: delete_meal,
    payload: id,
  });
};

try this :

export const deletemeal = (id) => async (dispatch) => {
  await fetch(`http://localhost:5000/api/meals/${id}/`, {
    method: "delete",
  });
  dispatch({
    type: delete_meal,
    payload: id,
  });
};

Related Query

More Query from same tag