In the modern tech world, most of the applications are revolve around client-side development. SharePoint also concentrated most on client side development from SharePoint 2010 onwards by introducing the different type of Client-side APIs. Below are the commonly used APIs for accessing SharePoint objects from the client side. They are
Refer the repository URL https://github.com/OfficeDev/PnP-JS-Core which contains the source of PnP JavaScript core library for SharePoint. We can clone from this GitHub location and start contributing to improving this library. This library supports from SharePoint 2013+ on-premises & SharePoint Online environment.So far the PnP team released a 1.0 major version and also released up to three minor versions. Find the details from below location about each version of PnP JS Core library,
https://blogs.msdn.microsoft.com/patrickrodgers/2016/06/06/pnp-js-library-1-0-0/
Complete Major Version
https://blogs.msdn.microsoft.com/patrickrodgers/2016/06/13/pnp-jscore-1-0-1/
JSON light for all environments, Bug fixes and additional features
https://blogs.msdn.microsoft.com/patrickrodgers/2016/06/28/pnp-jscore-1-0-2/
Caching and Batching, Bug fixes and additional features
https://blogs.msdn.microsoft.com/patrickrodgers/2016/07/27/pnp-jscore-1-0-3/
Support for Node, Bug fixes and additional features
function
getwebdetails() {
var
clientContext = SP.ClientContext.get_current();
// equivalent to SPContext.Current
oWeb = clientContext.get_web();
//Gets the current Web Object
clientContext.load(oWeb,
'Title'
,
'Description'
, );
clientContext.executeQueryAsync(
new
() {
strmsg +=
"<b>Web Title:</b> "
+ oWeb.get_description() + "
";
console.log(strmsg);
}, onFailed);
}
ExecuteOrDelayUntilScriptLoaded(getwebdetails,
"sp.js"
);
//Include jquery file to the SharePoint page
$.ajax({
url: _spPageContextInfo.webAbsoluteUrl +
"/_api/web?$select=Title,Description"
//THE ENDPOINT
method:
"GET"
headers: {
"Accept"
:
"application/json; odata=verbose"
},
success:
(data) {
//RESULTS HERE!!
console.log(
"Web: "
+ data.d.Title +
" - Description: "
+ data.d.Description);
});
//Include pnp.js file to the SharePoint page
$pnp.sp.web.get().then(
(web) {
console.log(web.Title +
' - '
+ web.Description);
Use the below code to use PnP JS in different environments,
//Set response type in headers
$pnp.setup({ headers: {
} });