vendredi 21 août 2015

Setting headers in the model hook via ajaxSetup (Ember)

I'm trying to set the headers before making my call and it's not working.

model: function() {
        debugger;

        Ember.$.ajaxSetup({
            beforeSend: function(xhr) {
                xhr.setRequestHeader(
                    'Authorization', 'bearer 123456'
                )
        }});

        return Ember.$.getJSON('http://addresss/api/locations').then(function(e) {
            debugger;
            console.log(e);
        });
    }

This keeps giving me the following error message:

No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access.

If I use Postman and set my header it works fine.




Aucun commentaire:

Enregistrer un commentaire