add request header on backbone

后端 未结 10 2155
伪装坚强ぢ
伪装坚强ぢ 2020-12-04 08:46

My server has a manual authorization. I need to put the username/password of my server to my backbone request inorder for it to go through. How may i do this? Any ideas? Tha

10条回答
  •  北荒
    北荒 (楼主)
    2020-12-04 09:34

    The easiest way to add request header in Backbone.js is to just pass them over to the fetch method as parameters, e.g.

    MyCollection.fetch( { headers: {'Authorization' :'Basic USERNAME:PASSWORD'} } );
    

提交回复
热议问题