I am conducting some testing and when I call the buylimit function I get an error.
My code is the following:
var assert = require('assert');
var bittrex = require('node.bittrex.api');
var fs = require('fs');
var config = JSON.parse(fs.readFileSync('./config.json'));
bittrex.options({
'apikey' : config.api.apiBittrex.key,
'apisecret' : config.api.apiBittrex.secret,
});
bittrex.buylimit({ market : tradingPair, quantity : quantityToBuy, rate : unitPrice }), function( data ) {
console.log("Order Executed"
}
this generate an order in Bittrex, but the code throw an error pointing to the following code in node.Bittrex.api.js (error in the last "callback" as highlighted below).
var sendRequestCallback = function(callback, op) {
var start = Date.now();
request(op, function(error, result, body) {
((opts.verbose) ? console.log("requested from " + op.uri + " in: %ds", (Date.now() - start) / 1000) : '');
if (!body || !result || result.statusCode != 200) {
var errorObj = {
success: false,
message: 'URL request error',
error: error,
result: result,
};
return ((opts.inverse_callback_arguments) ?
callback(errorObj, null) :
callback(null, errorObj));
} else {
result = JSON.parse(body);
if (!result.success) {
// error returned by bittrex API - forward the result as an error
return ((opts.inverse_callback_arguments) ?
callback(result, null) :
callback(null, result));
}
return ((opts.inverse_callback_arguments) ?
callback(null, ((opts.cleartext) ? body : result)) :
callback(((opts.cleartext) ? body : result), null)); // -> ERROR HERE
}
});
}
the error says:
Exception has occurred: TypeError TypeError: callback is not a function at Request._callback (c:\00 - Projects\node_modules\node.bittrex.api\node.bittrex.api.js:138:11) at Request.self.callback (c:\00 - Projects\node_modules\request\request.js:186:22) at emitTwo (events.js:126:13) at Request.emit (events.js:214:7) at Request.<anonymous> (c:\00 - Projects\node_modules\request\request.js:1163:10) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at IncomingMessage.<anonymous> (c:\00 - Projects\node_modules\request\request.js:1085:12) at Object.onceWrapper (events.js:313:30) at emitNone (events.js:111:20)
There's a bug in that code you supplied. The error is saying you're calling buylimit without a callback function, and if you look at the line you'll notice the ) isn't at the end of the line.
I am conducting some testing and when I call the buylimit function I get an error.
My code is the following:
this generate an order in Bittrex, but the code throw an error pointing to the following code in node.Bittrex.api.js (error in the last "callback" as highlighted below).
the error says:
Exception has occurred: TypeError TypeError: callback is not a function at Request._callback (c:\00 - Projects\node_modules\node.bittrex.api\node.bittrex.api.js:138:11) at Request.self.callback (c:\00 - Projects\node_modules\request\request.js:186:22) at emitTwo (events.js:126:13) at Request.emit (events.js:214:7) at Request.<anonymous> (c:\00 - Projects\node_modules\request\request.js:1163:10) at emitOne (events.js:116:13) at Request.emit (events.js:211:7) at IncomingMessage.<anonymous> (c:\00 - Projects\node_modules\request\request.js:1085:12) at Object.onceWrapper (events.js:313:30) at emitNone (events.js:111:20)
any help would be much appreciated