我正在尝试从API中获取数据
.service('Traffic', function ($http) {
var service = this;
service.getStops=function () {
return $http.get("https://api.resrobot.se/location.nearbystops.json?key=********&originCoordLat=******&originCoordLong=*******");
}
})
postman的API代表响应JSON
" "StopLocation" : [ {
"id" : "7459396",
"extId" : "7459396",
"name" : "Lilla Bommens Hamn (Göteborg kn)",
"lon" : 11.966035,
"lat" : 57.711816,
"weight" : 145,
"dist" : 136,
"products" : 256
"
但在应用程序中我得到了
"XMLHttpRequest cannot load https://api.resrobot.se/locatio***. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access."
有很多类似的问题,但所有问题都在使用localhost在同一台机器上运行api和app,我想知道如何在这里定义端点URL。