【发布时间】:2017-05-23 23:11:12
【问题描述】:
我正在尝试从this endpoint 获取结果。使用 GET 我得到 CORS 错误,所以我正在尝试 jsonp。
结果是
Refused to execute script from 'https://api.airbnb.com/v2/listings/16218947?client_id=3092nxybyb0otqw18e8nh5nty&_format=v1_legacy_for_p3&callback=angular.callbacks._0'
because its MIME type ('application/json') is not executable,
and strict MIME type checking is enabled.
我的代码是
var API_BASE_URL = 'https://api.airbnb.com/v2/';
function getListing(id) {
var url = API_BASE_URL + 'listings/' + id + '?client_id=3092nxybyb0otqw18e8nh5nty&_format=v1_legacy_for_p3';
var trusted = $sce.trustAsResourceUrl(url);
return $http.jsonp(trusted, {
jsonpCallbackParam: 'callback',
headers: {
'Accept': 'application/javascript'
}
});
};
【问题讨论】:
标签: javascript angularjs jsonp angular-http