fix(): fix unintentional pointer ref, fixes very rare sign issue if request is fired in parallel

This commit is contained in:
Tiago Siebler
2023-03-22 09:44:40 +00:00
parent c940f8e44f
commit dfb1534d22

View File

@@ -304,24 +304,31 @@ export default abstract class BaseRestClient {
isPublicApi
);
if (!options.headers) {
options.headers = {};
}
options.headers['ACCESS-KEY'] = this.apiKey;
options.headers['ACCESS-PASSPHRASE'] = this.apiPass;
options.headers['ACCESS-TIMESTAMP'] = signResult.timestamp;
options.headers['ACCESS-SIGN'] = signResult.sign;
options.headers['Content-Type'] = 'application/json';
const authHeaders = {
'ACCESS-KEY': this.apiKey,
'ACCESS-PASSPHRASE': this.apiPass,
'ACCESS-TIMESTAMP': signResult.timestamp,
'ACCESS-SIGN': signResult.sign,
'Content-Type': 'application/json',
};
if (method === 'GET') {
return {
...options,
headers: {
...authHeaders,
...options.headers,
},
url: options.url + signResult.queryParamsWithSign,
};
}
return {
...options,
headers: {
...authHeaders,
...options.headers,
},
data: params,
};
}