As I am new to SharePoint framework, I am using PnP JS core library in SharePoint webpart,please suggest how can I retrieve list items from SharePoint list via PnP JS core and CAML Query.

Please suggest any workaround for the same.

1 Answer 1


You can get items from SharePoint list using a CAML Query.

Sample Code:

import { ICamlQuery } from "@pnp/sp/lists";

// build the caml query object (in this example, we include Title field and limit rows to 5)
const caml: ICamlQuery = {
    ViewXml: "<View><ViewFields><FieldRef Name='Title' /></ViewFields><RowLimit>5</RowLimit></View>",

// get list items
const r = await list.getItemsByCAMLQuery(caml);

// log resulting array to console


  1. Get list items using a CAML Query
  • how can we display the retrieved line items Aug 21, 2020 at 13:08
  • It is totally based on which framework you are using and how you want to design your UI. Aug 21, 2020 at 13:37
  • I am using sharepoint wepart , how can loop the retrieved line items.... I using data.getEnumerator()...while this is not working.. Aug 21, 2020 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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