Hi @Aniruddha Aditya ,
There is no direct way to get the list items by specific view, you need to get the ViewQuery for this view. Then use the ViewQuery in CAML Query to get the listitems.
Below is my demo code for you:
import { sp } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
import "@pnp/sp/views";
import "@pnp/sp/items";
private async getListViewQuery(){
let list=sp.web.lists.getByTitle("Test1");
let view=await list.views.getByTitle("View1").select("ViewQuery")();
console.log(view.ViewQuery);
let xml = '<View><Query>' + view.ViewQuery + '</Query></View>';
let items= await list.getItemsByCAMLQuery({'ViewXml':xml});
console.log(items);
}
Reference: https://sharepoint.stackexchange.com/questions/264455/how-get-sharepoint-list-items-by-views-in-spfx
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.