Commit 8759a5dc by 王昆

gsb

parent 33683f42
...@@ -253,26 +253,39 @@ class ServiceBase { ...@@ -253,26 +253,39 @@ class ServiceBase {
} }
async callApi(url, data, name) { async callApi(url, data, name) {
let log = await this.synlogDao.create({ let res;
apiUrl: url, let log = await this.addSynLog(url, data, name);
apiName: name, try {
apiReq: JSON.stringify(data), res = await axios({
apiRes: "",
});
let res = await axios({
method: 'post', method: 'post',
url: url, url: url,
data: data data: data
}); });
if(log) {
console.log(res);
console.log(res.data);
log.apiRes = JSON.stringify(res.data); log.apiRes = JSON.stringify(res.data);
log.save(); log.save();
}
return res.data;
} catch (e) {
console.log(e);
}
return res.data; return res.data;
} }
async addSynLog(url, data, name) {
try {
return await this.synlogDao.create({
apiUrl: url,
apiName: name,
apiReq: JSON.stringify(data),
apiRes: "",
});
} catch (e) {
console.log(e)
}
return null;
}
trim(o) { trim(o) {
if (!o) { if (!o) {
return ""; return "";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment