角度提供程序出错

时间:2018-03-25 14:51:34

标签: angular angular-promise angular-providers

I have a behaviour that I am not understanding when using with promises with angular.
When I use  the same code as follows, I got my data correctly

@Injectable()
export class Request {

    constructor(public http: Http)
    {

    }

    get(url): Promise<any>
    {
        return this.http.get("https://api.github.com/repos/php/php-src").map(response => {
            console.log(response.json());
            return response.json() || {success: false, message: "No response from server"};
        }).toPromise();
    }

但是,当我将数据源更改为

http://mp3destadel.s3-website-eu-west-1.amazonaws.com/all.json

我收到此错误

Failed to load http://mp3destadel.s3-website-eu-west-1.amazonaws.com/all.json: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access.

请你帮我解决这个问题

此致

1 个答案:

答案 0 :(得分:1)

这不是一个有角度的问题。查看s3存储桶的CORS配置。

CORS documentation