我在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,还是直接添加到update方法?