node_modules/binance/lib/util/BaseRestClient.js
/**
     * @private Make a HTTP request to a specific endpoint. Private endpoints are automatically signed.
     */
@private Make a HTTP request to a specific endpoint. Private endpoints are automatically signed.
@private Make a HTTP request to a specific endpoint . Private endpoints are automatically signed .
_call(method, endpoint, params, isPrivate, baseUrlOverride) {
        return __awaiter(this, void 0, void 0, function* () {
            if (isPrivate) {
                if (!this.key || !this.secret) {
                    throw new Error('Private endpoints require api and private keys set');
                }
                if (this.timeOffset === null) {
                    yield this.syncTime();
                }
                params = yield this.signRequest(params);
            }
            const baseUrl = baseUrlOverride || this.baseUrl;
            const options = Object.assign(Object.assign({}, this.globalRequestOptions), { url: [baseUrl, endpoint].join('/'), method: method, json: true });
            if (method === 'GET') {
                options.params = params;
            }
            else {
                options.data = qs_1.default.stringify(params);
            }
            return axios_1.default(options).then(response => {
                this.updateApiLimitState(response.headers, options.url);
                if (response.status == 200) {
                    return response.data;
                }
                throw response;
            })
                .then(response => {
                if (!this.options.beautifyResponses || !this.beautifier) {
                    return response;
                }
                try {
                    return this.beautifier.beautify(response, endpoint) || response;
                }
                catch (e) {
                    console.error('BaseRestClient response beautify failed: ', JSON.stringify({ response: response, error: e }));
                }
                return response;
            })
                .catch(e => this.parseException(e, options.url));
        });
    }
_call ( method , endpoint , params , isPrivate , baseUrlOverride ) { return __awaiter ( this , void 0 , void 0 , function * ( ) { if ( isPrivate ) { if ( ! this . key || ! this . secret ) { throw new Error ( 'Private endpoints require api and private keys set' ) ; } if ( this . timeOffset === null ) { yield this . syncTime ( ) ; } params = yield this . signRequest ( params ) ; } const baseUrl = baseUrlOverride || this . baseUrl ; const options = Object . assign ( Object . assign ( { } , this . globalRequestOptions ) , { url : [ baseUrl , endpoint ] . join ( '/' ) , method : method , json : true } ) ; if ( method === 'GET' ) { options . params = params ; } else { options . data = qs_1 . default . stringify ( params ) ; } return axios_1 . default ( options ) . then ( response => { this . updateApiLimitState ( response . headers , options . url ) ; if ( response . status == 200 ) { return response . data ; } throw response ; } ) . then ( response => { if ( ! this . options . beautifyResponses || ! this . beautifier ) { return response ; } try { return this . beautifier . beautify ( response , endpoint ) || response ; } catch ( e ) { console . error ( 'BaseRestClient response beautify failed: ' , JSON . stringify ( { response : response , error : e } ) ) ; } return response ; } ) . catch ( e => this . parseException ( e , options . url ) ) ; } ) ; }
@private Make a HTTP request to a specific endpoint.
@private Make a HTTP request to a specific endpoint .
// Requests should be x-www-form-urlencoded // TODO: optimise in the browser to use URLSearchParams // console.log('sending request: ', JSON.stringify(options, null, 2)); // Fallback to original response if beautifier fails