Adding headers after RESTAdapter initialization

前端 未结 3 481
隐瞒了意图╮
隐瞒了意图╮ 2021-01-13 22:53

I am trying to add an Authorization header to my adapter\'s request after the adapter has been initialized and used. I can add headers in a static way at the t

3条回答
  •  北海茫月
    2021-01-13 23:03

    You should be able to use $.ajaxPrefilter to add custom headers (or params).

    See: http://api.jquery.com/jQuery.ajaxPrefilter/

    Ember.$.ajaxPrefilter(function( options, oriOptions, jqXHR ) {
      var auth= "Basic " + hash;
      jqXHR.setRequestHeader("Authorization", auth);
    });
    

提交回复
热议问题