Muhammad Ashikuzzaman Muhammad Ashikuzzaman - 2 months ago 13
AngularJS Question

Nodejs & Express : How to send multiple variable(Json Datatype) from server to Client through Render

I am using itunes-search module and express framework in nodejs. The search module returns different variables like software details, music details. I need Music artist details and song details. I can simply return the song details with the bellowed code. Here I had returned one variable through rendering. But I need to return two variable.
In client sides:

$scope.search_music_data = function(data)
var data="HamdunSoft";//Search my favourite artist name or band name
$http({'method' : 'post', url: '/search', data: {'search_item' : data}}).
$scope.artist_name = data;
$scope.check = true;

Bellowed codes are in server sides:

In route.js'/search', search.search_music);

In search_music function I did music search:

song="calculated data Json Data"
var response.send(song);

It is working. But I also need send another calculated data like

song="calculated data Json Data"
artist="calculated data Json Data"
var response.send(song,artist);

Is it possible by doing some tricks in search_music and search_music_data function? I will really appreciate him/her if he/she can help me.


Use this in server side code. I think this will help you. This is the example of multiple value sent from server to client.

res.send({artist: artist_details, music: music_details});

In client side :

you can access it data.artist & from angular controller.