[Vuejs]-Having issues with remove function on Express

0👍

You’re trying to pass a tip object as the request body, but DELETE requests aren’t supposed to have any body. Your DELETE route is expecting an ID, all you need to do is pass the ID of the tip you want to delete in the URL.

deleteMyTip(){
  fetch(`${API_URL}/${this.tipObject.id}`, {
    method: 'DELETE',
  })
  .then(response => {
    // Remove item from UI
  });
}

It’s also common practice to return an empty body with a 204 (no content) status.

Leave a comment