Merge pull request #57 from ianmcorvidae/non-json-traceroutes
Parse traceroute arrays when they don't show up as JSON already
This commit is contained in:
commit
adb60ede63
1 changed files with 6 additions and 1 deletions
|
|
@ -417,7 +417,12 @@ app.get('/api/v1/nodes/:nodeId/traceroutes', async (req, res) => {
|
||||||
const traceroutes = await prisma.$queryRaw`SELECT * FROM traceroutes WHERE want_response = false and \`to\` = ${node.node_id} and gateway_id is not null order by id desc limit ${count}`;
|
const traceroutes = await prisma.$queryRaw`SELECT * FROM traceroutes WHERE want_response = false and \`to\` = ${node.node_id} and gateway_id is not null order by id desc limit ${count}`;
|
||||||
|
|
||||||
res.json({
|
res.json({
|
||||||
traceroutes: traceroutes,
|
traceroutes: traceroutes.map((trace) => {
|
||||||
|
if (typeof(trace.route) === "string") {
|
||||||
|
trace.route = JSON.parse(trace.route);
|
||||||
|
}
|
||||||
|
return trace;
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch(err) {
|
} catch(err) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue