loopback/example/client-server/client.js

21 lines
469 B
JavaScript
Raw Normal View History

2014-02-19 19:44:16 +00:00
var loopback = require('../../');
var client = loopback();
var CartItem = require('./models').CartItem;
var remote = loopback.createDataSource({
connector: loopback.Remote,
2014-05-07 22:23:26 +00:00
url: 'http://localhost:3000'
2014-02-19 19:44:16 +00:00
});
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);
});