【发布时间】:2016-06-09 14:42:51
【问题描述】:
我一直在用 JavaScript 构建一个天气小部件。
我使用 angularjs($http 方法:get)来进行 api 调用。
使用下面的 API 调用获取天气信息没有问题(我的 api 密钥已被删除)
http://api.openweathermap.org/data/2.5/weather?q=Manchester,uk&appid=xxxxxxxx&units=metric
但是当我想切换到不同的 API(下面的 URL)时,我得到了错误
XMLHttpRequest 无法加载 https://api.forecast.io/forecast/33.499318,-2.234089000000026?units=si。请求的资源上不存在“Access-Control-Allow-Origin”标头。因此,不允许访问 Origin 'http://localhost:50301'。
这是因为第二个 API 使用 HTTPS 吗?但这没有意义。为什么第一个 api 被允许?
【问题讨论】:
标签: javascript api