How to get current page details in sharepoint using pnpjs
One of the easiest way to get sharepoint page details is by using pnpjs
You might have a question why I'm not Including all the steps, but since you know what to do I've skipped that part. So let's jump into it directly. Install pnpjs npm i @pnp/sp sp.web.lists. getByTitle ("Site Pages").items. getById ( props . context .pageContext.listItem.id). get (). then ( async ( r ) => { console.log(r)}) Here we are fetching current page details from the site page using the page id ( props . context . pageContext . listItem . id ) If you face any problem with context, then you need to configure the context in the webpart.ts
Canonical URL: https://khangkhuiphungdhar.vercel.app/read/how-to-get-current-page-details-in-sharepoint-using-pnpjs