how do I setup a server json file for node and an angularjs website as client? My client is a website which is created with angularjs. How do I setup this to send requests to the server and get response from there? My server is a node server. How do I setup the json file to communicate with my client?
Asked
Active
Viewed 627 times
1 Answers
0
Check out node-json-rpc.
You can declare a method on the (node) server side like this
server.addMethod('myMethod', function (params, callback) {
var error, result;
//implementation here
callback(error, result);
});
and call it on the client side (angular) like this:
client.call(
{"method": "myMethod", "params": [1,2]},
function (error, result) {
//Handle result
}
);

user7091295
- 1
- 1
-
Thank you. Is it correct that this example is for the http communication where the client is pulling and synchron? – FeelGood Oct 30 '16 at 19:38