Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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