Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Moving from 1.0.* to 2.0.*

Patrick Rodgers edited this page Apr 22, 2017 · 8 revisions

As we move to 2.0.0 it represents a breaking change from the 1.0.* versions - though we've done our best to minimize the work on your end. That being said, read below as you may have some work to do in your solutions. This is meant to be a living document so if we missed something please let us know - or update the article :).

Update Node to 6.9.* (latest LTS version)

This supports a broad range of JavaScript modern features in node. If you are concerned about compatibility with older projects you can use nvm or nvm-windows to manage multiple versions of node.

Update how you use NodeFetchClient or SPRequestExecutorClient

Previously there were individual settings used with the pnp.setup method to configure the node fetch client (for working in node) or the SPRequestExecutor (when working in add-in webs). These have been replaced with a single setting that takes a factory method for the fetch client you wish to use for your requests. This grants full control over what is executing your requests, and simplifies the setup of the library.

Setup NodeFetchClient

import { setup, Web, NodeFetchClient } from "sp-pnp-js";

setup({
    fetchClientFactory: () => {
        return new NodeFetchClient("{site url}", "{client id}", "{client secret}");
    }
});

let w = new Web("{site url}");

w.select("Title").get().then(w => {
    console.log(w);
});

Setup SPRequestExecutorClient

import { setup, sp, SPRequestExecutorClient } from "sp-pnp-js";

setup({
    fetchClientFactory: () => {
        return new SPRequestExecutorClient();
    }
});

let w = sp.crossDomainWeb("{add-in web url}", "{host web url}");

w.select("Title").get().then(w => {
    console.log(w);
});

What happened to provisioning??

We have separated the provisioning code into its own repo. This will better allow the focus of this library to remain on core functionality while allowing the provisioning library to grow and evolve inline with community contributions.

Clone this wiki locally