Skip to content

Commit 6a4d662

Browse files
committed
good to go!
1 parent fcbd676 commit 6a4d662

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

app.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const port = 80;
2222
// Are we in test mode?
2323
console.log ("Test Mode: ", binance.getOption('test'));
2424

25-
// Make the EventEmitter that will be triggered by our webhooks
25+
2626
var eventEmitter = new events.EventEmitter();
2727

2828
eventEmitter.on('error', (err) => {
@@ -35,10 +35,6 @@ eventEmitter.on('error', (err) => {
3535
* For a limit order just add a third parameter, 'price', to marketBuy
3636
*/
3737
eventEmitter.on('buy', () => {
38-
if (error) {
39-
console.error(error);
40-
return;
41-
}
4238
binance.marketBuy(symbol, quantity, (error, response) => {
4339
if (error) {
4440
console.error(error);
@@ -54,9 +50,6 @@ eventEmitter.on('buy', () => {
5450
* For a limit order just add a third parameter, 'price', to marketSell
5551
*/
5652
eventEmitter.on('sell', () => {
57-
if (error) {
58-
console.error(error);
59-
}
6053
binance.marketSell(symbol, quantity, (error, response) => {
6154
if (error) {
6255
console.error(error);
@@ -82,9 +75,12 @@ const server = http.createServer((req, res) => {
8275
body = Buffer.concat(body).toString();
8376
if(body === 'buy') {
8477
eventEmitter.emit('buy'); // <----------------------- BUY
85-
} else {
78+
}
79+
80+
if(body === 'sell') {
8681
eventEmitter.emit('sell'); // <---------------------- SELL
87-
}
82+
}
83+
8884
console.log(body);
8985
res.statusCode = 200;
9086
res.end();

0 commit comments

Comments
 (0)