如何解决无法设置未定义的属性“状态”
我的脚本运行良好,但最后我收到一条错误消息,脚本执行过程中出现错误。
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;
},};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。