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

编程入门 行业动态 更新时间:2024-10-04 07:31:06

错误 node.js <a href=https://www.elefans.com/category/jswz/34/1771452.html style=应用程序:动作和模块的顶级主体(在 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)

本文发布于:2024-05-31 03:37:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1771230.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   模块   主体   错误   动作

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!