When receiving a response from the server, it appears in this format:
{"value1":1,"value2":45,"value3":"x"}
{"value1":1,"value2":45,"value3":"x"}
{"value1":1,"value2":45,"value3":"x"}
The response is in text form.
I'm having trouble parsing the JSON due to an error saying "Unexpected token {". Can someone assist me in converting this into a valid object?
UPDATE 1
The output after using the following code:
const arr = `[${res.replaceAll('\n', ',')}]`
Is:
[{"value1":1,"value2":45,"value3":"x"},
{"value1":1,"value2":45,"value3":"x"},
{"value1":1,"value2":45,"value3":"x"}]
It seems there is an issue with the last comma when copying the data manually. This error does not occur in that case.
UPDATE 2
Furthermore, the server response contained invisible empty lines that I initially overlooked. Using trim() function fixed this issue.