【发布时间】:2015-11-06 08:24:39
【问题描述】:
我刚开始使用 Nodejs。
我正在使用 Restify 从以下位置获取数据:http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo'。
下面的代码给了我一个错误:{"code":"ResourceNotFound","message":"/ 不存在"}
var restify =require("restify");
var server = restify.createServer();
server.use(restify.acceptParser(server.acceptable));
server.use(restify.queryParser());
server.use(restify.bodyParser());
server.get('http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo', function (req, res) {
console.log(req.body);
res.send(200,req.body);
});
server.listen(7000, function () {
console.log('listening at 7000');
});
【问题讨论】:
标签: javascript node.js restify