Running pnp in modern script editor spfx web part, can add items, get items from a list, but cannot delete items from a list:

$pnp.sp.web.lists.getByTitle('List Name').items
    .filter('Title eq Test')

Error shows up in console:

DELETE https://xxx.sharepoint.com/sites/TeamIT/spfx-sfd/_api/web/lists/getByTitle('List Name')/items?$filter=Title eq Test 400 (Bad Request)

If I take the url and drop it into Chrome, it returns the item properly.

What on earth am I missing with something this simple? Lots of documentation in pnp on how to delete a list, didn't find much for list items, is there something unique that must be submitted with a delete to get it to operate properly?

  • You could refer my answer, hope it helps! Commented Oct 24, 2018 at 16:33

2 Answers 2


You delete it using batch request as below:

var batch = $pnp.sp.createBatch();

var list = $pnp.sp.web.lists.getByTitle("List Name");

list.items.filter("Title eq 'test'").get().then((items) =>{ 

  items.forEach(i =>{
    list.items.getById(i["ID"]).inBatch(batch).delete().then(r => {

  batch.execute().then(() => console.log("All deleted"));

  • This worked for me, looks like a syntax issue kept the above code from functioning: var batch = $pnp.sp.createBatch(); var varTitle = "Title eq '" + userObj + "'"; var list = $pnp.sp.web.lists.getByTitle("<List Name>"); list.items.filter(varTitle).get().then((items) =>{ items.forEach(i =>{ list.items.getById(i["ID"]).inBatch(batch).delete().then(r => { console.log("deleted"); }); }); batch.execute().then(() => console.log("Deleted item")); });
    – Dodge1350
    Commented Oct 26, 2018 at 16:17
  • @Dodge1350 - cool, happy to help. You can accept it as answer by ticking the checkbox besides the answer. Commented Oct 29, 2018 at 11:54

Try below code:

$pnp.sp.web.lists.getByTitle('List Name').items
    .filter('Title eq "Test"')
  • You cannot do like this, pnpjs don't have delete method on filter
    – Milind
    Commented Sep 6, 2022 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.