我是 Node.js 的新手,正在通过示例学习。
这就是我想要做的,我有一个运行的地理服务器来为 GeoJson 提供服务,我想调用地理服务器 WFS url 并使用 node.js 获取 json 数据。这是代码,当我运行它时,我得到:
getaddrinfo ENOENT
var http = require('http');
var options = {
host: "local:8080/geoserver/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=layername&outputFormat=JSON&cql_filter=id=1";
path: '/'
}
var request = http.request(options, function (res) {
var data = '';
res.on('data', function (chunk) {
data += chunk;
});
res.on('end', function () {
console.log(data);
});
});
request.on('error', function (e) {
console.log(e.message);
});
request.end();
请指导我正确的方向。谢谢。
最佳答案
您需要传递正确的选项:
host - 应该只是主机名
path - 应该是主机上资源的路径(主机名后的所有内容
方法 - 应该是 GET 或 POST(在你的情况下是 GET)。
var options = {
host: "local:8080";
path: '/geoserver/wfs?service=WFS&version=1.0.0&request=GetFeature&typeName=layername&outputFormat=JSON&cql_filter=id=1',
method: 'GET'
}
关于node.js - 使用 node.js 来自 Geoserver 的 GeoJson,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12862685/