I am encountering an issue with the data returned from my server:
reminder:"["15", {"reminder_server": Balancer #5, "reminder_day": 16}]"
My goal is to extract the values of reminder_server
and reminder_day
, and I have attempted the following approach:
if (typeof data.reminder !== 'undefined' && data.reminder.length > 0) {
var remind = data.reminder;
for( var k = 0; k < remind.length; k+=2 ) {
var id = remind[k];
var reminder = remind[k+2];
/* ADD - reminder */
console.log(reminder.reminder_server);
/* INCREMENT - counter */
k++;
}
}
However, when I check the output using console.log
, I always receive either:
28 undefined
Or
]
I am unsure about the cause of this discrepancy. On the server side, I am converting the string to a JSON object and sending it to the client using Node.js:
res.json(data);
Any insights or suggestions on resolving this issue would be greatly appreciated.