我正在尝试编写lon和lat api,但不会返回所述值。(node.js)

我正在尝试使用geocodify api链接编写带有lat和lon结束标记的api调用,

这是结果ejs

<h1>this is the result</h1>
    <p>lattitude point:</p><%=result['response']['geocoding']['query']['point.lat'] %>
    <p>longitude point:<%=result['response']['geocoding']['query']['point.lon'] %></p>

结果以这种方式获得json。

{
  "meta": {
    "code": 200
  },
  "response": {
    "geocoding": {
      "version": "api.v2",
      "attribution": "https://geocodify.com/attribution",
      "query": {
        "size": 10,
        "private": false,
        "point.lat": 58, //trying to retrieve this
        "point.lon": -57,//and this
        "boundary.circle.lat": 58,
        "boundary.circle.lon": -57,
        "lang": {
          "name": "English",
          "iso6391": "en",
          "iso6393": "eng",
          "defaulted": true
        },
        "querySize": 20
      },
      "timestamp": 1589179251298,
      "terms": "https://geocodify.com/terms"
    },
    "type": "FeatureCollection",
    "features": [
    ]
  }
}

但我得到空结果

lattitude point:
longitude point:

而不是得到

lattitude point:58
longitude point:-57

后端代码就是这样,app.js

var express = require('express');
app = express();
bodyPraser = require('body-parser');
request = require('request');

app.set('view engine', 'ejs');

app.get('/', function(req, res) {
    res.render('index');
});
app.post('/formPost', function(req, res) {
    var lat = req.params.lat;
    var lon = req.params.lon;
    var url1 = "https://api.geocodify.com/v2/reverse?api_key=6cbf8c5fe0ae304ab7a1af6a6bbe81f88767e3c0&";
    request(url1 + "&lat=" + lat + '&lng=' + lon, function(err, resp, body) {
        if (!err && resp.statusCode == 200) {
            var uttar = JSON.parse(body);
            res.render("result", { result: uttar });
        }
    })

})
app.listen(3000, function(req, res) {
    console.log('successfully connected');
})

没有错误,我尝试产生其他结果,其他结果很容易显示,但我的结果未显示。

评论