应用程序:动作和模块的顶级主体(在 index.js:13:21)"/>
错误 node.js 应用程序:动作和模块的顶级主体(在 index.js:13:21)
了解了很多,但是没弄明白为什么会报这个错:
Only valid in async functions and the top level bodies of modules (at index.js:13:21)
这是代码:
async function run() {
console.log("running...");
const config = {
auth: {
clientId: 'xxxxxxxxxxxxxxxxxxxx',
authority: '/',
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);
}
从前端页面调用run函数:
<button type="button" class="btn btn-primary btn-lg" onclick="run()">
<i class="fa fa-fw fa-inverse fa-play"></i>
Run Code
</button>
回答如下:
更多推荐
错误 node.js 应用程序:动作和模块的顶级主体(在 index.js:13:21)
发布评论