📜  如何在 Angular 11 中为 api 传递基本身份验证 - Javascript 代码示例

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

代码示例1
import { HttpHeaders } from '@angular/common/http';

const httpOptions = {
  headers: new HttpHeaders({
    'Content-Type':  'application/json',
    'Authorization': 'Basic ' + btoa('username:password')
  })
};