使用angular 1.5 $ http服务访问API时出现404错误

时间:2017-06-07 19:24:05

标签: angularjs ajax cors

当我在浏览器中查看时,我有一个完全可见的API网址。我可以看到Json文件和标题如下。

Connection  close
Content-Type    application/json
Date    Wed, 07 Jun 2017 18:59:50 GMT
Server  WildFly/8
Strict-Transport-Security   max-age=15768000
X-Backend-Server    docker2
X-Powered-By    Undertow/1

我正在尝试使用$ http获取此Json对象,我的代码如下所示

var url = "url that I am trying to reach"   
$http({
 method: 'JSONP',
 url: url,
}).then(function successCallback(response) { //do something }

我知道标题中不允许使用Access-Control-Allow-Origin,但我得到的响应是404错误

Object {
  data: false,
  status: 404,
  config: Object,
  statusText: "error",
  headers: function
}

任何见解都表示赞赏。我正在使用棱角1.5

0 个答案:

没有答案