0
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.

你能帮我解决这个问题吗

问候

4

1 回答 1

1

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

CORS 文档

于 2018-03-25T15:00:54.640 回答