从平衡节点模块响应中检索链接和属性时出现问题

Problems retrieving links and properties from balanced-node module responses

我一直在为 node.js 使用新的平衡节点模块,它似乎是由 Q promises 驱动的。我肯定做错了什么,因为当我比较 Balanced API 文档上的响应与我从这个插件得到的响应时,它们是完全不同的。

我正在尝试通过 运行 创建客户:

    balanced.marketplace.customers.create({
        name: "John Smith",
        email: "test@test.com",
        phone: "2222222222"
    })
    .then(function(customer) {
        // this prints out a big object which looks like the properties of the module,
        // I expected this to print out the sample response as seen in the API docs.
        console.log(customer);

        // when i run this, it prints out the actual name that was added. 
        console.log(customer.name);

        // but I can't seem to get the various source URLs that the sample response shows.
    });

谁能给我一个关于如何使用平衡节点模块正确执行此操作的可靠示例?

您在文档中看到的示例响应是来自 cURL 请求的 JSON 响应,可能不是您从客户端库中实际看到的。

也就是说,要很好地打印对象的格式化 JSON 表示,您应该使用以下方法而不是 console.log:

function print(obj) {
  console.log('string' === typeof obj ? obj : JSON.stringify(obj, null, 4));
}