【发布时间】:2021-06-19 03:23:46
【问题描述】:
我有一个执行发布请求的函数,它是这样的,现在在后端我有基本身份验证,这意味着我必须在这个请求中传递标题用户名和密码才能成功调用 api,我尝试了类似的东西这并没有成功..
clickSubmit(event) {
let httpHeaders = new HttpHeaders();
httpHeaders.append('Content-Type', 'application/json');
httpHeaders.append("Authorization", "Basic " + btoa("00000:magical"));
const httpOptions = {
headers: httpHeaders
};
let user = {
"userId": this.userId,
"userName": this.name,
"adharno": this.adharno,
"pancardno": this.pancardno,
"address": this.address,
"joineddate": this.joinedDate
}
const base_URL = 'http://localhost:8090/v1/users'
return this.http.post(base_URL, user, httpOptions);
}
【问题讨论】:
标签: javascript angularjs angular