Add HTTP basic authentication to this HTTP GET in angularjs

前端 未结 2 1568
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 20:47

I have an existing angularjs code which makes a HTTP GET. Extracted below is some relevant code inside the controller.

    .controller(\'imptViewCtrl\', [\'$         


        
2条回答
  •  时光取名叫无心
    2020-12-16 21:38

    Rather than using a library to encode your auth by base 64, you could just use:

    window.btoa("user:pass")

    it's supported by most browsers.

    https://developer.mozilla.org/en-US/docs/Web/API/WindowBase64/btoa

提交回复
热议问题