0
我想在我的ajax請求中添加一個授權標頭,但我無法達到它。標題定製失敗
import Ember from 'ember'
AppsRoute = Ember.Route.extend
model: (params) ->
return Ember.RSVP.hash
count: $.getJSON window.Cockpit.API_URL + "apps/count/" + params.year
accumulation: $.getJSON window.Cockpit.API_URL + "apps/accumulation/" + params.year
setupController: (controller, model, queryParams) ->
controller.set 'model', model.count
controller.set 'accumulation', model.accumulation
controller.set 'param', queryParams.params.apps.year
export default AppsRoute
我延長了RESTAdapter類這樣的:
import DS from 'ember-data'
AppAdapter = DS.RESTAdapter.extend
headers:
'Authorization': 'Basic XXX'
export default AppAdapter
但我的頭不存在的請求。
任何人都可以幫助我嗎? 謝謝, 加布裏埃爾
這可能會有所幫助http://stackoverflow.com/questions/21490476/adding-headers-after-restadapter-initialization – atinder
謝謝,但遵循文檔http://emberjs.com/api/data/classes/DS .RESTAdapter.html#toc_headers-customization,這是做到這一點的正確方法 –