【发布时间】:2018-08-04 06:09:03
【问题描述】:
我正在尝试使用 Axios 发送 HTTP 请求,但收到 404 错误。原因是请求在 URL 的开头使用本地主机 IP 发送,为什么会发生这种情况?
JS:
function getWeather() {
axios.get('api.openweathermap.org/data/2.5/weather', {
params: {
lat: 30.18,
lon: 30.87,
appid: '57d9478bc08bc211f405f45b93b79272'
}
})
.then(function(response) {
console.log(response);
})
.catch(function(error) {
console.log(error);
})
};
getWeather();
错误:
http://127.0.0.1:5500/api.openweathermap.org/data/2.5/weather?lat=30.18&lon=30.87&appid=57d9478b#####################3b79272 404 (Not Found)
【问题讨论】:
标签: javascript http axios