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,31 +516,37 @@ 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;
}); });
} }
resolve();
});
});
response.status(200).json({ response.status(200).json({
status: 200, status: 200,
timestamp: Date.now(), timestamp: Date.now(),
message: 'Peers list fetched successfully', message: 'Peers list fetched successfully',
response: { response: {
dataJson dataJson: result
}, },
}); });
}); });
});
} catch (error) { } catch (error) {
console.log('error 3###########', error); console.log('error 3###########', error);
next(new InternalServerErrorException(error)); next(new InternalServerErrorException(error));