Created
August 30, 2019 08:16
-
-
Save joelfmrodrigues/911ef8677f6672c9dafbaa70a0bcebff to your computer and use it in GitHub Desktop.
Get frequent sites
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'; | |
const contextRawResponse = await this._httpClient.get(contextEndpointUrl, HttpClient.configurations.v1, contextRequestOptions); | |
const context = await contextRawResponse.json(); | |
// get data | |
const dataRequestHeaders: Headers = new Headers(); | |
dataRequestHeaders.append("Authorization", "Bearer " + context.Token.access_token); | |
dataRequestHeaders.append("sphome-apicontext", context.Payload); | |
const dataRequestOptions: IHttpClientOptions = { | |
headers: dataRequestHeaders, | |
}; | |
const dataEndpointUrl = context.Urls[0] + `/api/v1/sites/feed?start=0&count=${count}&acronyms=true`; | |
const dataRawResponse = await this._httpClient.get(dataEndpointUrl, HttpClient.configurations.v1, dataRequestOptions); | |
const data = await dataRawResponse.json(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment