【问题标题】:(node:21484) UnhandledPromiseRejectionWarning: TypeError: manager.push is not a function(节点:21484)UnhandledPromiseRejectionWarning:TypeError:manager.push 不是函数
【发布时间】:2021-06-06 10:40:07
【问题描述】:

对于在我的团队资料生成器中选择的每个角色,我不断收到以下错误消息:

(node:21484) UnhandledPromiseRejectionWarning: TypeError: manager.push is not a function 在 C:\Users\User\OneDrive\Desktop\Team Profile Generator\GOTEAMGO\index.js:48:29
在 processTicksAndRejections (internal/process/task_queues.js:93:5)

then(({ fullname, id, email, role }) => {
        if (role === "Manager") {
            let manager = "";
            return inquirer
                .prompt([{
                    type: 'text',
                    name: 'office',
                    message: " What is the Office Number?"
                }])
                .then(({ office }) => {
                    manager.push(new Manager(fullname, id, email, office))
                    teammates.push(manager);
                    cardhtml(teammates)
                    html();
                })

【问题讨论】:

    标签: node.js


    【解决方案1】:

    您的manager 变量是一个字符串。在 javascript 中,没有为字符串定义 push 函数。你能不能换个试试,

    let manager = "";
    

    let manager = [];
    

    【讨论】:

      猜你喜欢
      • 2018-03-23
      • 2021-09-20
      • 2020-07-24
      • 2021-02-28
      • 1970-01-01
      • 1970-01-01
      • 2019-12-05
      • 2021-09-19
      • 2016-12-10
      相关资源
      最近更新 更多