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
// within your web part onInit method, get the request digest token | |
const digestCache: IDigestCache = this.context.serviceScope.consume(DigestCache.serviceKey); | |
const requestDigest = await digestCache.fetchDigest(this.context.pageContext.web.serverRelativeUrl); | |
//now on your data access layer | |
// get token | |
const authRequestHeaders: Headers = new Headers(); | |
authRequestHeaders.append("Accept", "application/json;odata.metadata=minimal"); | |
authRequestHeaders.append("Content-Type", "application/json; charset=utf-8"); |
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
// get data endpoints, token and payload | |
const contextRequestHeaders: Headers = new Headers(); | |
contextRequestHeaders.append("Accept", "application/json;odata.metadata=minimal"); | |
contextRequestHeaders.append("odata-version", "4.0"); | |
const contextRequestOptions: IHttpClientOptions = { | |
headers: contextRequestHeaders, | |
}; | |
const contextEndpointUrl = this._webAbsoluteUrl + '/_api/sphomeservice/context?$expand=Token,Payload'; |