Reputation: 103
It is necessary to obtain data from https://forkdelta.io using api https://github.com/forkdelta/backend-replacement/tree/master/docs/api
Here is the code:
var http = require("http");
http.createServer(function(request, response) {
const io = require('socket.io-client');
socket = io.connect('https://api.forkdelta.com', { transports:
['websocket'] });
socket.on('connect', function() {
console.log('socket connected');
socket.emit('getMarket', {
token: "0x6fff3806bbac52a20e0d79bc538d527f6a22c96b",
user: "" });
});
socket.on('market', function(payload) {
console.log(payload.orders.buys);
});
}).listen(3000);
console.log("Server has started.");
I save it in server.js and execute the command node server.js
I run the code at the link http: // localhost: 3000 from the local server - hangs
I run the code from here https://repl.it/repls/DeafeningBlushingAddons - successfully
Please help me figure out how to correctly run the code from the browser. Next, we intend to parse the data array and convert it to a table.
Upvotes: 0
Views: 236
Reputation: 137
Please check the console from where you are executing this code, it is actually fetching the data you require...
This is what the data looks like
{ id: '0xd7ff1f49ffde2380b1fd42877b8ce573bfb2c1cace509b1edcb07e757fa13889_buy',
user: '0x5b38d2298666c89efe5f1819347a6004b93bbbe2',
state: 'OPEN',
tokenGet: '0x6fff3806bbac52a20e0d79bc538d527f6a22c96b',
amountGet: '3.50e+22',
tokenGive: '0x0000000000000000000000000000000000000000',
amountGive: '3.500e+15',
expires: '104747875',
nonce: '1340442292',
v: 27,
r: '0xc929ec3f336b4641d84545d27764c43470946c3119221c856c8f72ac3f625edb',
s: '0x5a79fe5728fb47d22c837ae322bff8b43f3de638ddfa3ee5122bf344a0e507dc',
date: '2018-02-14T20:18:30.052233',
updated: '2018-10-02T10:06:53',
availableVolume: '3.15e+18',
ethAvailableVolume: '3.150000000',
availableVolumeBase: '3.150e+11',
ethAvailableVolumeBase: '3.150000000e-7',
amount: '-3.15e+18',
amountFilled: '0',
price: '1e-7' }
Upvotes: 3