I have this JSON data here and I want to get all the data that corresponds to an id. EG: id 1 would contain service1 and 1.0. i need it to loop through however many lines there are and tell me the details for that id. EG: id1 contains service1 & 1.0, id2 contains service2 & 2.0 and so forth with however many lines there are.
[
{ id: 1, serviceName: 'Service1', serviceVersion: '1.0' },
{ id: 2, serviceName: 'Service2', serviceVersion: '2.0' },
{ id: 3, serviceName: 'Service3', serviceVersion: '3.0' },
{ id: 4, serviceName: 'Service4', serviceVersion: '4.0' }
]
I have gotten this far with actually selecting the data from the database and formatting it.
app.post("/check", (request, response) => {
con.query('SELECT id, serviceName, serviceVersion FROM system_db.system', function (error, result) {
var data = JSON.parse(JSON.stringify(result));
console.log(data);
});
});