Pure JavaScript code for HTTP Basic Authentication?

前端 未结 2 671
抹茶落季
抹茶落季 2020-11-27 12:56

Where can I find reference code that implements a HTTP Basic Authentication client in pure JavaScript, suitable for AJAX?

Extra points for code, or pointers to code,

2条回答
  •  爱一瞬间的悲伤
    2020-11-27 13:15

    The five-parameter version of the XMLHttpRequest.open method allows you to specify the username and password. (WHATWG spec)

    xhr.open(method, url, async, username, password)
    

提交回复
热议问题