Giter VIP home page Giter VIP logo

spscript's Introduction

SPScript


Join the chat at https://gitter.im/DroopyTersen/spscript

Visit https://spcript.com for full documentation.

SPScript is a collection of javascript helpers for the SharePoint Rest API. Some features include...

  • Easy querying of list data.
  • Add and Update list items in 1 line of code.
  • Easily utilize SharePoint search
  • Work with the Profile Service
  • Check permissions on sites and lists
  • Work with CustomActions

Installation

Add the SPScript npm package to your project

NPM

npm install spscript

Yarn

yarn add spscript

Importing

You can use SPScript in your Javascript/Typescript files with:

import SPScript from "spscript";

ProTip: Dynamically/Temporarily add SPScript to a Modern page with Dev Tools

You can enter the following into a browser console to dynamically load SPScript on a page.

let script = document.createElement("script");
script.src = "https://unpkg.com/spscript@beta/dist/spscript.browser.js";
document.head.appendChild(script);

SPScript Context

Almost everything in SPScript is based off an SPScript Context class.

  • An SPScript Context is tied to specific SharePoint site.
  • You get a Context by calling SPScript.createContext(siteUrl).

You get a Context by calling SPScript.createContext(siteUrl).

This line of code is the entry point to almost everything SPScript provides.

let ctx = SPScript.createContext(siteUrl);

Example Usage: Get the News Pages of the specified site.

import SPScript from "spscript";

const getPublishedNews = async function (siteUrl) {
  let ctx = SPScript.createContext(siteUrl);
  let pages = await ctx.lists("Site Pages").findItems("PromotedState", 2);
  console.log(pages); // This will show an Array of Page List Items
  return pages;
};

Throughout the docs you'll see a variable, ctx, representing an instance of an SPScript Context.

Troubleshooting

If you are using Typescript, you may have to use the syntax:

import * as SPScript from "spscript";

If you don't like that, add "allowSyntheticDefaultImports": true to your tsconfig.json.

spscript's People

Contributors

droopytersen avatar bschlintz avatar rizrmd avatar gitter-badger avatar chnbohwr avatar lpmi-13 avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.