I've learned a lot about it, but I didn't figure it out why I got this error:
Only valid in async functions and the top level bodies of modules (at index.js:13:21)
That's the code:
async function run() {
console.log("running...");
const config = {
auth: {
clientId: 'xxxxxxxxxxxxxxxxxxxx',
authority: 'https://login.microsoftonline.com/organizations/',
redirectUri: 'http://localhost:8080'
}
};
var client = new msal.PublicClientApplication(config);
var loginRequest = {
scopes: [ 'user.read' ]
};
let loginResponse = await client.loginPopup(loginRequest);
console.log('Login Response', loginResponse);
}
The run function is called from front-end page:
<button type="button" class="btn btn-primary btn-lg" onclick="run()">
<i class="fa fa-fw fa-inverse fa-play"></i>
Run Code
</button>