我有一个Angular 6服务,我试图更改一条记录,但它显示我没有授权。
现在我有这个:
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
};
update(id, title, content) {
const updateData = { id: id, title: title, content: content };
return this.http.put(`http://myurl/${id}`, updateData, httpOptions);
}
我的问题是:
如何将基本授权添加到我的httpOptions中,或者我直接将其添加到更新方法中?