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: "", method: 'post',
}); url: url,
data: data
let res = await axios({ });
method: 'post', if(log) {
url: url, log.apiRes = JSON.stringify(res.data);
data: data log.save();
}); }
return res.data;
console.log(res); } catch (e) {
console.log(res.data); console.log(e);
log.apiRes = JSON.stringify(res.data); }
log.save();
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