(node:21484) UnhandledPromiseRejectionWarning: TypeError: manager.push is not a function

时间:2021-06-06 01:59:46

标签: node.js

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

(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();
                })

1 个答案:

答案 0 :(得分:0)

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

let manager = "";

let manager = [];