yhtx 1.0.4 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +35 -4
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -62,15 +62,46 @@ async function call(path, { apiKey, secret, data, method, recvWindow } = {}) {
|
|
|
62
62
|
...(method == "POST" && { data }), //must be "data" //if GET, don't send
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
// let r = await axios(config)
|
|
66
|
+
// .then((r) => {
|
|
67
|
+
// if (!(r.data?.code == 200 /*success*/ || r.data?.status == "ok"))
|
|
68
|
+
// console.log(r.data); //if not code:200 or status:ok, then log
|
|
69
|
+
// let rs = r.data.data;
|
|
70
|
+
// return rs;
|
|
71
|
+
// })
|
|
72
|
+
// .catch(function (e) {
|
|
73
|
+
// console.log(e.response.data);
|
|
74
|
+
// }); //old
|
|
65
75
|
let r = await axios(config)
|
|
66
76
|
.then((r) => {
|
|
67
|
-
|
|
68
|
-
|
|
77
|
+
let dt = r.data;
|
|
78
|
+
if (dt?.code == 403 && msg == "Verification failure [校验失败]") {
|
|
79
|
+
console.log("api bug: null"); //{code:403,msg:'Verification failure [校验失败]',data:null,ts:1758849372250}
|
|
80
|
+
} else if (dt?.status == "error") {
|
|
81
|
+
if (dt?.["err-code"] == "api-signature-not-valid") {
|
|
82
|
+
console.log("api bug2: null"); ////{status: 'error','err-code': 'api-signature-not-valid','err-msg': 'Signature not valid: Verification failure [校验失败]',data:null}
|
|
83
|
+
} else if (dt?.err_code == 403) console.log("api bug3: undefined"); //{status:"error",err_code:403,err_msg:"Verification failure [校验失败]",ts:1758854139970};
|
|
84
|
+
} else if (dt?.message == "Verification failure [校验失败]" && dt?.code == 1003) {
|
|
85
|
+
console.log("api bug4: undefined"); //{ message: 'Verification failure [校验失败]', code: 1003, success: false }
|
|
86
|
+
} else if (dt?.message == "Verification failure" && dt?.code == 12008) {
|
|
87
|
+
console.log("api bug5: null"); //{ code: 12008, message: "Verification failure", data: null };
|
|
88
|
+
} else if (!(r.data?.code == 200 /*success*/ || r.data?.status == "ok")) {
|
|
89
|
+
console.log(r.data); //if not code:200 or status:ok, then log //
|
|
90
|
+
} //eg{message:'The account API interface queried is empty',code:40237,success:false}
|
|
91
|
+
|
|
69
92
|
let rs = r.data.data;
|
|
70
|
-
|
|
93
|
+
if (rs == null && dt?.status == "error") {
|
|
94
|
+
rs = r.data; //eg rs={status:"error","err-code":"dw-withdraw-precision-limit","err-msg":"withdraw amount precision cannot be greater than 6",data:null}
|
|
95
|
+
} else if (rs == undefined) {
|
|
96
|
+
if (![dt?.err_msg, dt?.message].includes("Verification failure [校验失败]")) {
|
|
97
|
+
rs = r.data; //eg rs={message:'The account API interface queried is empty',code:40237,success:false}
|
|
98
|
+
} // if (dt?.success == false && dt?.code != 1003 && /*bug3*/ dt?.err_code != 403) {
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return rs; //rs=DATA | {status:'error','err=code','err-msg',data:null} | null(if api fail) | undefined(if apiFail)
|
|
71
102
|
})
|
|
72
103
|
.catch(function (e) {
|
|
73
|
-
console.log(e.response
|
|
104
|
+
console.log(e.response?.data);
|
|
74
105
|
});
|
|
75
106
|
|
|
76
107
|
return r;
|