Hello! I’m working in one application in Ionic 2 and I’m connecting it with node.js server. For send data (server - Ionic) I send like this:
http.createServer(function (req, res){
…
res.end(data); // data is 0 or 1
}
In Ionic, I get the data like this:
this.http.post(“http://192.168.1.100:8080/post”, ‘PidoDatosClima’ + ‘_’ + this.parameter1)
.subscribe(data => {
resp=data.json()
console.log(resp);
…
Where resp is 0 or 1 so… in this example work fine.
My problem is when I need to send more data in my server so… if in “res.end(data)” data is the string “1_2_3”
In Ionic, I get this error: “EXCEPTION: SyntaxError: Unexpected token _ in JSON at position 1”
Somebody know how can I solve it? Thanks in advance.
Best regards.