Javascript 无法设置属性';状态';未定义的
我的脚本运行良好,但在脚本执行过程中,最后我收到一条错误消息errorJavascript 无法设置属性';状态';未定义的,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("
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()语法混用!