sp-context-helper
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

sp-context-helper Build Status

Get associated SP.Web and SP.Site by url.

Installation

npm install sp-context-helper --save

Usage

JavaScript

import { contextHelper } from 'sp-context-helper';
 
let contextWrapper = contextHelper('web url');

TypeScript

typings install dt~microsoft.ajax --global --save
typings install dt~sharepoint --global --save
/// <reference path="./typings/index.d.ts"/>
 
import { contextHelper, IContextWrapper } from 'sp-context-helper';
 
let contextWrapper: IContextWrapper = contextHelper('web url');

API

interface IContextWrapper {
    web: SP.Web;
    site: SP.Site;
    clientContext: SP.ClientContext;
    appContextSite: SP.AppContextSite;
}
 
contextHelper(webUrl?: string, isAppContextSite?: boolean): IContextWrapper

To query current web, use contextHelper(), to query host web, use contextHelper('host url', true), to query web in same domain, use contextHelper('web url').

License

MIT.

Readme

Keywords

Package Sidebar

Install

npm i sp-context-helper

Weekly Downloads

1

Version

1.0.3

License

MIT

Last publish

Collaborators

  • frederick-s