首页 > 解决方案 > 发出打开天气 api 的 http 请求时出现未知错误

问题描述

我在我的 stckblitz 项目中进行了 http 调用

http://api.openweathermap.org/data/2.5/weather?q=' + data.city + '&appid=' + this.APIKey

但它总是给出一个错误

Http failure response for http://api.openweathermap.org/data/2.5/weather?q=london&appid=6492527f849e5034d485df6b5981d407: 0 Unknown Error

https://stackblitz.com/edit/angular-open-weather-app

标签: angularstackblitz

解决方案


您应该使用httpsurl 的版本:

https://api.openweathermap.org/data/2.5/weather?q=' + data.city + '&appid=' + this.APIKey


推荐阅读