Skip to content Skip to sidebar Skip to footer

How Can I Send My Json To My View With Node Js

I have a previous question about this so take a look here. I can now login to spotify and get the playlists of the user that is loged in. I now want to send these playlists (they a

Solution 1:

In that case, you can use an ajax request to the server with a library of your choice, and when you receive the data after the ajax, you update your view using the data. With jQuery you might do something like:

var jqxhr = $.get('/playlist', {parameters});
jqxhr.done(function(data){
//data is your json response you can manipulate.
});

You might also want to use res.json() witch is more appropriate to send json responses in express.

Solution 2:

If you want to send a JSON you can do this

return res.status(200).json({ "text": "Hello World!" });

Post a Comment for "How Can I Send My Json To My View With Node Js"