From 3ee713818228b7b9b6c356fa2e915cc5be64a496 Mon Sep 17 00:00:00 2001 From: liamcottle Date: Sun, 8 Sep 2024 13:04:48 +1200 Subject: [PATCH] ensure new fields are json arrays in response --- src/index.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 05a06f7..cf704fc 100644 --- a/src/index.js +++ b/src/index.js @@ -439,10 +439,29 @@ app.get('/api/v1/nodes/:nodeId/traceroutes', async (req, res) => { res.json({ traceroutes: traceroutes.map((trace) => { - if (typeof(trace.route) === "string") { + + // ensure route is json array + if(typeof(trace.route) === "string"){ 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; + }), });