ensure new fields are json arrays in response
This commit is contained in:
19
src/index.js
19
src/index.js
@ -439,10 +439,29 @@ app.get('/api/v1/nodes/:nodeId/traceroutes', async (req, res) => {
|
|||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
traceroutes: traceroutes.map((trace) => {
|
traceroutes: traceroutes.map((trace) => {
|
||||||
|
|
||||||
|
// ensure route is json array
|
||||||
if(typeof(trace.route) === "string"){
|
if(typeof(trace.route) === "string"){
|
||||||
trace.route = JSON.parse(trace.route);
|
trace.route = JSON.parse(trace.route);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensure route_back is json array
|
||||||
|
if(typeof(trace.route_back) === "string"){
|
||||||
|
trace.route_back = JSON.parse(trace.route_back);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure snr_towards is json array
|
||||||
|
if(typeof(trace.snr_towards) === "string"){
|
||||||
|
trace.snr_towards = JSON.parse(trace.snr_towards);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure snr_back is json array
|
||||||
|
if(typeof(trace.snr_back) === "string"){
|
||||||
|
trace.snr_back = JSON.parse(trace.snr_back);
|
||||||
|
}
|
||||||
|
|
||||||
return trace;
|
return trace;
|
||||||
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user