我是Node.js的新手,通过示例学习.
这是我想要做的,我有一个geoserver运行服务GeoJson,我想调用geoserver 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();
Run Code Online (Sandbox Code Playgroud)
请指导我正确的方向.谢谢.
小智 5
您需要传递正确的选项:
host - 应该只是主机名
path - 应该是主机上资源的路径(主机名后的所有内容)
方法 - 应该是GET或POST(在你的情况下获取).
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'
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1712 次 |
最近记录: |