Skip to content
This repository was archived by the owner on Aug 28, 2024. It is now read-only.

Install and Use

Russell gove edited this page May 20, 2016 · 24 revisions

Within a TypeScript project

  1. NPM Install

    npm install sp-pnp-js --save

  2. Import to TypeScript file

    import pnp from "sp-pnp-js";

  3. Begin using the API

    pnp.sp.web.get().then(...)

You can also import parts of the library into your project to use them directly:

import { objectIsNull } from "sp-pnp-js/lib/utils/args";

let b = objectIsNull(null); //true

From a Content Editor WebPart (untested script)

  1. **Download pnp.js from here ???

  2. **Upload pnp.js to your site. In this example we will upload it to a library called "Style Library"

  3. Add a new file called pnptest.html to the same library with the following content.

<script type="text/javascript" src="{PathToYourSite}/Style%20Library/pnp.js"></script>

<script type="text/javascript" src="{PathToYourSite}/Style%20Library/pnptest.js"></script>

<div id="main">

</div>

  1. Add a new file called testpnp.pnptest.js to the same library with the following content.

  2. Add a Content Editor WebPart to a page within the site/

  3. ** Set the url of the content editor webpart to "{PathToYourSite}/Style%20Library/pnptest.html"

Clone this wiki locally