Last active
February 13, 2017 11:23
-
-
Save beckettkev/f627b00eb191149d59ee28595140d518 to your computer and use it in GitHub Desktop.
Getting the Client Context for the file upload.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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