fix(接口定义): 修复接口没有用例时初始添加报错问题

This commit is contained in:
fit2-zhao 2021-03-18 16:05:08 +08:00
parent e8f56b1787
commit 13adca8f57
2 changed files with 6 additions and 3 deletions

View File

@ -222,7 +222,9 @@
}
this.result = this.$post("/api/testcase/list", this.condition, response => {
this.apiCaseList = response.data;
if(response.data){
this.apiCaseList = response.data;
}
this.apiCaseList.forEach(apiCase => {
if (apiCase.tags && apiCase.tags.length > 0) {
apiCase.tags = JSON.parse(apiCase.tags);
@ -236,7 +238,7 @@
}
})
if (!this.useEnvironment && this.apiCaseList[0].request && this.apiCaseList[0].request.useEnvironment) {
if (!this.useEnvironment && this.apiCaseList[0] && this.apiCaseList[0].request && this.apiCaseList[0].request.useEnvironment) {
this.useEnvironment = this.apiCaseList[0].request.useEnvironment;
this.environment = this.useEnvironment;
}

View File

@ -524,7 +524,8 @@ export default {
this.$emit('editApi', row);
},
runApi(row) {
let request = JSON.parse(row.request);
let request = row ? JSON.parse(row.request) : {};
if (row.tags instanceof Array) {
row.tags = JSON.stringify(row.tags);
}