Adding a custom header to HTTP request using angular.js

前端 未结 8 1826
说谎
说谎 2020-11-27 13:01

I am a novice to angular.js, and I am trying to add some headers to a request:

   var config = {headers: {
            \'Authorization\': \'Basic d2VudHdvcnR         


        
8条回答
  •  再見小時候
    2020-11-27 13:26

    For me the following explanatory snippet worked. Perhaps you shouldn't use ' for header name?

    {
       headers: { 
          Authorization: "Basic " + getAuthDigest(), 
          Accept: "text/plain" 
       }
    }
    

    I'm using $http.ajax(), though I wouldn't expect that to be a game changer.

提交回复
热议问题