PnP-JS-Core library contains the number of extensible methods and properties. By using that we can achieve the various actions in a simple code. To know more about this library component, visit the below links,
SharePoint has lot of building blocks in collections which are used to form a SharePoint site. Those are used in manage the contents, generate reports based on contents & settings, etc…
In this post, we will use the PnP-JS-Core method to get the root web site from the Site collection.
pnp.sp.site.rootweb – Gets the root web of the site collection
The below steps and code snippet used to returns the root web object and properties from the current site collection.
- Download Required files to use PnP-JS-Core library from the below links and upload that to Site Asstes or Style Library
- Download pnp.js PnP JS file
- Download fetch.js Used by PnP js file to handle web requests and responses (Required in IE)
- Download promise.js Used by PnP js file to handle web requests and responses (Required in IE)
- Create new web part page and insert Content Editor web part
- Create a sample.html file in Site Assets or Style library and insert the below code snippet
- Add the URL of sample.html file to the content editor webpart
- Click ok to apply the changes to the webpart and save the page.
- Now the page displays the title and description of the root website.