Giter Site home page Giter Site logo

sprequest's Introduction

SPRequest

This library is used to make SharePoint API request simpler.

Usage / Examples

Importing

There are 2 options initializing the scripts. If no url defined it will try to use the SharePoint URL available.

// If URL is undefined it will use the SharePoint URL available

// create a new instance passing in a desired url.
import SPRequest from "SPRequest";
const spReq = new SPRequest("URL");

// Or use the predefined value spRequest. Uses "_spPageContextInfo.siteAbsoluteUrl" as default url.
import { spRequest as spReq } from "SPRequest";

UpdateDefaultUrl Method

Used to change the default base url used by all methods. Useful if using the predefined SPRequest or getting all data from a diffrent sharepoint site or subsite.

Usage example

spReq.updateDefaultUrl("URL");

Get Method

Used to make a request to sharepoint API to get list data. This method returns a promise. You can use then/catch to deal with results.

Usage example

// Get the first 100 of a given list
spReq.lists
    .get("ListName")
    .then(data => console.log(data))
    .catch(err => console.log(err));

// Get all items
spReq.lists.get("ListName", true);

// Get file's info from document library (top 100)
spReq.lists.get("ListName", false, true);
spReq.lists.get("ListName", "files");

// Get all file's info
spReq.lists.get("ListName", true, true);

You can also pass objects and arrays to the get method.

spReq.lists.get({ list: "ListName" });

spReq.lists.get([
    {
        list: "ListName",
        baseUrl: "/subsite"
    },
    "ListName2"
]);

Usefull Lists

Some usefull lists that are part of a sharepoint site.

Name Discription
lists Get a list of all lists
currentuser Get infomation on the current user.
siteusers Get a list of all sites users.
sitegroups Get a list of all the sites user groups.

Options

Property Type Default Example Discription
list String "lists" "ListName" The name of the list.
baseUrl String null "/subsite" Get list from a subsite from your default url.
select String null "ID,Title,Created,LookupColumn" Select individual column(s) of the request list.
expand String null "LookupColumn/Title" Expand to get data from any lookup column(s).
filter String null "Created ge datetime'2020-01-15T00:00:00.000Z'" Apply filter to data being collected.
getAll Boolean false false Promises will be deferred to get all.
Note: Use "top" to limit the number of requests.
getFiles Boolean false false Get file info from a document library.
order String null "Created desc"
get new items
The order that the data will be collected.
Note: This is not to sort the data just the order they are received.
top Number 100 10 Get "X" number of items.
Note: Used with "getAll" set batch size for each deferred promise.

sprequest's People

Contributors

thomascarman avatar

Watchers

 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.