Skip to content

Instantly share code, notes, and snippets.

@beckettkev
Last active February 13, 2017 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beckettkev/f627b00eb191149d59ee28595140d518 to your computer and use it in GitHub Desktop.
Save beckettkev/f627b00eb191149d59ee28595140d518 to your computer and use it in GitHub Desktop.
Getting the Client Context for the file upload.
function getWebRequestExecutorFactory(appWebUrl, hostWebUrl, spLanguage) {
let context = new window.SP.ClientContext(appWebUrl);
const factory = new window.SP.ProxyWebRequestExecutorFactory(appWebUrl);
context.set_webRequestExecutorFactory(factory);
return context;
}
const jsomContext = (appWebUrl, hostWebUrl, spLanguage) => {
return getWebRequestExecutorFactory(appWebUrl, hostWebUrl, spLanguage);
};
const jsomAppContext = (appWebUrl, hostWebUrl, spLanguage) => {
let context = getWebRequestExecutorFactory(appWebUrl, hostWebUrl, spLanguage);
// Use the host web URL to get a parent context - this allows us to get data from the parent
let hostWebContext = new SP.AppContextSite(context, hostWebUrl);
return hostWebContext;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment