最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

错误 node.js 应用程序:动作和模块的顶级主体(在 index.js:13:21)

网站源码admin32浏览0评论

错误 node.js 应用程序:动作和模块的顶级主体(在 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>
回答如下:
发布评论

评论列表(0)

  1. 暂无评论