PnPjs is a collection of fluent libraries for consuming SharePoint, Graph, and Office 365 REST APIs in a type-safe way. You can use it within SharePoint Framework, Nodejs, or any JavaScript project.
PnPjs is a collection of fluent libraries for consuming SharePoint, Graph, and Office 365 REST APIs in a type-safe way. You can use it within SharePoint Framework, Nodejs, or any JavaScript project.
- Website: https://pnp.github.io/pnpjs/
- GitHub: https://github.com/pnp/pnpjs
Getting Started
Install the library and required dependencies
npm install @pnp/sp --save
Import the library into your application and access the root sp object
import { sp } from "@pnp/sp";
import "@pnp/sp/webs";
import "@pnp/sp/lists";
// get the list by Id
const list = sp.web.lists.getById("03b05ff4-d95d-45ed-841d-3855f77a2483");
// we can use this 'list' variable to execute more queries on the list:
const r = await list.select("Title")();
// show the response from the server
console.log(r.Title);