2

The delete () function of the IComments interface (PnP) does not delete the comment I select through the index, how can I use it? (@pnp/sp/comments)

in this way I get the comments of the item to which I will pass the index, but once I try to use the delete it is not read.

SiCaMa
  • 25
  • 4

1 Answers1

1

Use the clear method exposed by IComments. The clear method would delete all comments on the item returned.

  const item = sp.web.lists.getByTitle('Title').items.getById(1);
  await item.comments.clear();

Or you could use the snippet below which will delete the comment with the specified id.

  const commentId = 2000;
  await item.comments.getById(commentId).delete();
ayodele
  • 186
  • 5