如何处理 node-zillow 的结果?

How to process the results from node-zillow?

项目的 zillow 包。我已经成功执行了 GetSearchResults() 并获得了响应,但我不完全知道如何处理响应以从中获取信息。例如,这是来自调用的终端中的日志:

{ request:
   { address: '113 Cherry St',
     citystatezip: 'Seattle, Washington' },
  message: { text: 'Request successfully processed', code: '0' },
  response: { results: { result: [Array] } } }

我看到我有一个名为 result 的数组,我认为其中包含信息,但我该如何处理它?

谢谢

从文档看来,您正在处理承诺。所以我建议简单地这样做:

 GetSearchResults() 
 .then(function(results) {
    //handle your results here for instance
    console.log(results) 
  })

您似乎在使用 node-zillow 软件包。我注册了一个 zillow api 密钥来玩这个包。难以相信官方 API 只有 returns XML...

导航结果 JSON 并打印出第一个 results、第一组 links,并获取其第一个 homedetails url。

const Zillow = require('node-zillow');

// get key from environment variable
const z = new Zillow(process.env.ZWSID);

const params = {
  address: '2512 Mapleton Ave.',
  citystatezip: '80304',
};

// store the results
const results = await z.get('GetSearchResults', params);

const homeDetails = results.response.results.result[0].links[0].homedetails[0];

console.log(homeDetails);

打印出

https://www.zillow.com/homedetails/2512-...