はbalanced.marketplace.customers.create
バックグラウンドでネットワーク呼び出しを実行し、プロミスを返します。これは、リソースの基になるデータにアクセスすることを意味します。使用する必要があります.then
var customer = balanced.marketplace.customers.create(...);
customer.then(function(c) {
console.log(c.href);
});
これがあなたを混乱させた理由は、バランスの取れたノード ライブラリが使用するプロミスが「オーバーロード」されているためです。つまり、アクションをつなぎ合わせることができます。.then
promise の結果にアクセスする場合にのみ使用する必要があります。これは、次のようなことができることを意味します。
var card = balanced.get('/cards/CCasdfadsf'); // this is a network call
var customer = balanced.marketplace.customers.create(); // this is a network call that will go in parallel
card.associate_to_customer(customer).debit(5000); // using promises these will complete once all the previous request are complete
customer.then(function (c) {
console.log(c.href); // since we need to access the data (href) on the customer, we have to wait for the non blocking requests to complete and then the data will be ready.
});