How can I send an obect to javascript in the client's side? I asked earlier a question and was answered and accepted the question because I couldnt check the answer on the computer: Client receive json object to javascript
I still dont understand how to send the data to the client I tried req.send/render and it didnt get to function in the client's side.
client:
$.get('127.0.0.1:3000', {mydata: 'content'}, function(response){
//callback triggered when server responds
console.log(JSON.stringify(response));
});
server:
app.get('/', function (req, res) {
if(req.params.mydata === 'content'){
res.end("you sent content");
} else {
res.end("you sent something else");
}
});
Thank you!