【发布时间】:2018-07-16 01:05:37
【问题描述】:
我正在尝试运行 Binance 的基本公共 API。 https://api.binance.com/api/v3/ticker/price
当我在浏览器中打开它时,它工作正常,但是当我在我的 Angular 代码中使用它时。我收到错误访问控制允许来源。我也尝试将它添加到我的标题中以避免它,但这不起作用。这是我的代码。
headers1 = new Headers({ 'Content-Type': 'application/json', 'Access-Control-Allow-Headers': 'Content-Type' });
getData() {
return this.http.get('http://www.api.binance.com/api/v3/ticker/price', { headers: this.headers1 });
}
【问题讨论】: