【问题标题】:not able to consume thezipcodes.com search api data无法使用 thezipcodes.com 搜索 api 数据
【发布时间】:2021-04-27 17:44:41
【问题描述】:

我是nodejs的新手,我想使用www.thezipcodes.com/api/v1/search api来搜索邮政编码定位。

我无法使用 API 返回的位置。

const request = require('request');
request('https://thezipcodes.com/api/v1/search?zipCode=13040&countryCode=US&apiKey=<apiKey>', (err, res, body) => {
    if (err) { return console.log(err); }    
    console.log(body.location);
});

输出是

undefined

在 curl 中给出输出,但在 nodeapi 中我无法使用位置数组。

【问题讨论】:

    标签: javascript node.js api geocoding zipcode


    【解决方案1】:

    您应该按照文档中给出的示例进行操作。 您正在接收来自字符串的 JSON 响应。请先将 body 对象解析为 JSON,然后再使用结果。

    【讨论】:

      猜你喜欢
      • 2011-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多