loopback/example/client-server/client.js

22 lines
499 B
JavaScript

var loopback = require('../../');
var client = loopback();
var CartItem = require('./models').CartItem;
var remote = loopback.createDataSource({
connector: loopback.Remote,
root: 'http://localhost:3000',
remotes: client.remotes()
});
client.model(CartItem);
CartItem.attachTo(remote);
// call the remote method
CartItem.sum(1, function(err, total) {
console.log('result:', err || total);
});
// call a built in remote method
CartItem.find(function(err, items) {
console.log(items);
});