Question

I want to use PnP JS Core in SPFx v1.0.2 React webpart for SP16 On-premise server .

  • What is the version of pnp need to use and how to install it?
  • What are the other options for accessing data in SP with this version(1.0.2)?
Était-ce utile?

La solution

SPFx for SharePoint 2016 currently uses Typescript 2.1.x.

The pnp compatible version for that is version 2.0.8. The latest version 3.0.0 throws some errors because of some breaking changes.

To install that, you need to run the below command:

npm install sp-pnp-js@2.0.8 --save

Update - the latest version 3.0.x works just fine, just that you need to setup the library as below:

pnp.setup({
    sp: {
        headers: {
            "Accept": "application/json; odata=verbose"
        }
    }
});

To install it, just need to run the below command:

npm install sp-pnp-js@latest --save

Reference - Moving from PnP JS core 2.0.x to 3.0.x

PnP JS core configuration

The alternate to that is to use the sphttpclient to perform CRUD operations.

You can find an excellent example here. Check the noFramework webpart.

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top