【发布时间】:2016-01-09 20:06:00
【问题描述】:
我正在开发一个ionic 应用程序,试图访问MEAN.JS 应用程序的API,如下所示,它是编码JSON 的链接
https://damp-dawn-2579.herokuapp.com/api/foods
我的应用程序的工厂服务访问上面的链接却报错了
XMLHttpRequest cannot load http://localhost:3000/api/foods. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.
工厂服务
.factory('Foods', ['$resource',
function($resource) {
return $resource('https://damp-dawn-2579.herokuapp.com/api/foods/:foodId', { foodId: '@_id'
}, {
update: {
method: 'PUT'
}
});
}
])
我该如何克服这个问题? 谢谢
【问题讨论】:
标签: angularjs xmlhttprequest ionic-framework meanjs