Created
April 8, 2021 21:20
-
-
Save vipulgupta2048/6c742e74e86399acdeb575ee37e00054 to your computer and use it in GitHub Desktop.
Token Fetcher, Immersive Reader Launcher
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
tokenGetOverHereandLaunch() { | |
fetch(tokenURL, { credentials: `include`, cache: "no-store" }) | |
.then(response => response.json()) | |
.then(body => { | |
// https://docs.microsoft.com/en-us/azure/cognitive-services/immersive-reader/reference#chunk | |
const data = { | |
chunks: [{ | |
content: htmlContent, | |
lang: "en-us", | |
mimeType: "text/html" | |
}] | |
}; | |
// https://docs.microsoft.com/en-us/azure/cognitive-services/immersive-reader/reference#options | |
const options = { | |
uiLang: "en-us", | |
timeout: 90, | |
uiZIndex: 5, | |
useWebview: true, | |
onExit: () => console.log("Closing Immersive Reader"), | |
allowFullscreen: false, | |
hideExitButton: false, | |
cookiePolicy: CookiePolicy, | |
disableFirstRun: false, | |
readAloudOptions: ReadAloudOptions, | |
translationOptions: TranslationOptions, | |
displayOptions: DisplayOptions, | |
} | |
// The backend service needs to be configured to fetch the token from the authentication directory | |
launchAsync(body.token, body.subdomain, data, options) | |
.catch(function (error) { | |
console.log(`Error in launching the Immersive Reader: ${error}`); | |
}); | |
}) | |
.catch((error) => { | |
console.error(`Error: ${error}`); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment