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

@ -76,7 +76,7 @@ app.use(function(req, res, next) {
res.header('Access-Control-Allow-Origin', '*'); res.header('Access-Control-Allow-Origin', '*');
res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS'); res.header('Access-Control-Allow-Methods', 'GET,PUT,POST,DELETE,OPTIONS');
res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With, Accept, Authtoken,cookie_id'); res.header('Access-Control-Allow-Headers', 'Content-Type, Authorization, Content-Length, X-Requested-With, Accept, Authtoken,cookie_id');
// intercept OPTIONS method // intercept OPTIONS method
if ('OPTIONS' == req.method) { if ('OPTIONS' == req.method) {
return res.status(200).end(); return res.status(200).end();
@ -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);
if(dataJson.length > 0){
dataJson.forEach(function (value, i) { let dataJson = self.IsJsonString(data);
value['id'] = i; if(dataJson.length > 0){
});
} result = dataJson.map(function (value, i) {
response.status(200).json({ value['id'] = i;
status: 200, return value;
timestamp: Date.now(), });
message: 'Peers list fetched successfully', }
response: { resolve();
dataJson });
}, });
}); response.status(200).json({
status: 200,
timestamp: Date.now(),
message: 'Peers list fetched successfully',
response: {
dataJson: result
},
}); });
}); });
} catch (error) { } catch (error) {