我有一個.wep API服務,它工作正常。當我想從Angularjs App.browser控制檯獲取數據時,給了我這個錯誤。Angular 2 Rest服務請求
getCurrentFeed() :Observable<Tweet[]>{
return this.http.get('http://localhost:6010/GetTweets').map((resp :Response)=>{
console.log(resp.json());
var fetchedTweets=[];
for(let tweet of resp.json().data)
{
fetchedTweets.push(this.getTweetFromJson(tweet));
}
return fetchedTweets as Array<Tweet>;
});
}
XMLHttpRequest無法加載http://localhost:6010/GetTweets。請求的資源上沒有「Access-Control-Allow-Origin」標題。因此不允許訪問原產地'http://localhost:4200'。 error_handler.js:54 EXCEPTION:狀態響應:0表示URL:null
我該如何在這裏應用標題 –