Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法设置属性';状态';未定义的_Javascript_Node.js_Error Handling_Properties - Fatal编程技术网

Javascript 无法设置属性';状态';未定义的

Javascript 无法设置属性';状态';未定义的,javascript,node.js,error-handling,properties,Javascript,Node.js,Error Handling,Properties,我的脚本运行良好,但在脚本执行过程中,最后我收到一条错误消息error Cannot set property 'status' of undefined. 有人知道我做错了什么吗 const fs = require("fs-promise"); const axios = require("axios"); const jsonxml = require("jsonxml"); const tmp = require("

我的脚本运行良好,但在脚本执行过程中,最后我收到一条错误消息error

Cannot set property 'status' of undefined.
有人知道我做错了什么吗

const fs = require("fs-promise");
const axios = require("axios");
const jsonxml = require("jsonxml");
const tmp = require("tmp");

module.exports = {
  mpGetChecklist: async function (mpurl, bearer, systemGetChecklistMethod, systemGetChecklistId, systemGetChecklistDatasetName) {
    var getChecklist = {
      method: systemGetChecklistMethod,
      url: mpurl + "/connector/system/getChecklist?id=" + systemGetChecklistId,
      headers: {
        Authorization: "Bearer " + bearer,
      },
    };

    let tmpPath = tmp.fileSync({ postfix: ".xml" });
    let result;
    await axios(getChecklist)
      .then(function (response) {
        console.log(JSON.stringify(response.data));
        let xmlOptions = { header: true, root: "JSON", indent: true };
        let xmlString = jsonxml(response.data, xmlOptions);
        try {
          fs.writeFileSync(tmpPath.name, xmlString);
          result = { status: "succes", xmlPath: tmpPath.name, datasetName: systemGetChecklistDatasetName };
        } catch (error) {
          result = { status: "error", msg: error };
        }
      })
      .catch(function (error) {
        console.log(error);
      });

    return result;
  },
};

我没有看到任何试图设置
状态的内容。错误发生在哪一行?不要将
async
/
wait
then()语法混用!