OpenWeather APP返回404
问题描述:
我正在开发一个天气应用程序,并试图从OpenWeather API访问某个区域的天气,但是我的HTTP请求仍然得到了404响应。我试过了我能想到的一切,找不到问题。我的HTTP请求在下面,我尝试了各种不同的位置规范(GPS,城市,城市代码)和不同的位置,但我得到的是404。任何想法?OpenWeather APP返回404
var xhr = new XMLHttpRequest;
xhr.open("GET", "api.openweathermap.org/data/2.5/weather?id=2172797&APPID=58e1db4c51d420f0e05367be9cd66132", false);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");
xhr.send();
console.log(xhr);
'api.openweathermap.org/... '是一个路径相对的URL。也许尝试用'http:// api.openweathermap.org'。此外,使用Firebug/Chromebug /无论您使用的浏览器是什么,您都会注意到访问的地址是错误的。 –