I'm trying to fetch items from a specific view of a Sharepoint list in SPFX using @pnp/sp library but I'm unable to do so. I'm able to fetch the view properties and fields of the list. I didn't find anything as such to fetch the items of that view. How will I be able to acheive the same and also my list contains Lookup columns as well.


1 Answer 1


Sample test code for your reference.

sp.web.lists.getByTitle('MyDoc2').views.getByTitle("All Documents").get().then((view: any) => {
        ViewXml: `<View><Query>`+view.ViewQuery+`</Query></View>`
      }).then((items: any) => {
  • Thankyou for your response. The list has Lookup fields as well so, how do I expand those fields using this method getItemsByCAMLQuery? Commented Jun 8, 2020 at 9:00
  • If the lookup filed displays in your view, you could get the lookup item id as items[i].TestLookupId, TestLookup is the lookup field.
    – Lee
    Commented Jun 8, 2020 at 9:11

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.