且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用axios发送基本身份验证

更新时间:2023-12-01 07:50:15

基本身份验证有一个 auth参数:

There is an "auth" parameter for Basic Auth:

auth: {
  username: 'janedoe',
  password: 's00pers3cret'
}

来源/文档: https://github.com/mzabriskie/axios

示例:

await axios.post(session_url, {}, {
  auth: {
    username: uname,
    password: pass
  }
});