嗨,我是网络编程的新手,我想通过javascript练习一些API用法。 我尝试请求基本的openwatcher API调用:
API调用:
api.openweathermap.org/data/2.5/weather?q={city name}
示例:
var request = require('request');
request("api.openweathermap.org/data/2.5/weather?q=London",function(error,response,body){
if(!error && response.statusCode == 200){
console.log(body)
}
else{
console.log(error);
console.log(response.statusCode)
}
})
但输出错误
错误:无效的URI“ api.openweathermap.org/data/2.5/weather?q=伦敦”
这里可能是什么问题?