📜  带有基本身份验证和错误的 Axios GET Req - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:04:29.460000             🧑  作者: Mango

代码示例2
const err = await axios.
  get('https://httpbin.org/basic-auth/foo/bar', {
    auth: {
      username: 'foo',
      password: 'baz' // Bad password
    }
  }).
  catch(err => err);
err.message; // "Request failed with status code 401"
err.response.status; // 401 "Unauthorized"