Get peer issue fixed

This commit is contained in:
raja.blaze 2019-08-09 15:45:17 +05:30
parent d6ca5440fa
commit 550e69568c
2 changed files with 25 additions and 19 deletions

View File

@ -87,7 +87,6 @@ app.use(function(req, res, next) {
} }
); );
app.use(errorMiddleware);
app.use(bodyParser.json({ limit: "50mb" })); app.use(bodyParser.json({ limit: "50mb" }));
app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.urlencoded({ extended: false }));
app.use( app.use(
@ -111,6 +110,7 @@ controllers.forEach(controller => {
app.get("/epic_explorer/v1/**", (req, res) => { app.get("/epic_explorer/v1/**", (req, res) => {
res.send({ msg: "Api works." }); res.send({ msg: "Api works." });
}); });
app.use(errorMiddleware);
// * NOTE :: leave this as require() since this file is built Dynamically from webpack // * NOTE :: leave this as require() since this file is built Dynamically from webpack
const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require("./server/main"); const { AppServerModuleNgFactory, LAZY_MODULE_MAP } = require("./server/main");

View File

@ -516,29 +516,35 @@ export class BlockchainKernelController {
) => { ) => {
var self = this; var self = this;
try { try {
http.get('http://116.203.152.58:3413/v1/peers/connected', (resp) => { http.get('http://116.203.152.58:3413/v1/peers/connected',
async (resp) => {
// console.log('resp resp respresp',resp); // console.log('resp resp respresp',resp);
let data = ''; let data = '';
let result ;
// A chunk of data has been recieved. // A chunk of data has been recieved.
await new Promise((resolve) => {
resp.on('data', function (chunk) { resp.on('data', function (chunk) {
data += chunk; data += chunk;
let dataJson = self.IsJsonString(data); let dataJson = self.IsJsonString(data);
if(dataJson.length > 0){ if(dataJson.length > 0){
dataJson.forEach(function (value, i) { result = dataJson.map(function (value, i) {
value['id'] = i; value['id'] = i;
}); return value;
} });
response.status(200).json({ }
status: 200, resolve();
timestamp: Date.now(), });
message: 'Peers list fetched successfully', });
response: { response.status(200).json({
dataJson status: 200,
}, timestamp: Date.now(),
}); message: 'Peers list fetched successfully',
response: {
dataJson: result
},
}); });
}); });
} catch (error) { } catch (error) {