【发布时间】:2021-02-06 11:05:48
【问题描述】:
我对这个 CURL 请求有疑问。如果我通过终端发送它可以正常工作,但是当我将其转换为 Angular HTTP 客户端调用时它不起作用。
卷曲:
curl --location --request PUT '<some_url>' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
"status": "CONFIRMED"
}'
角度:
const headers = new HttpHeaders()
.set('Content-Type', 'application/json')
.set('Accept', 'application/json; charset=UTF-8');
const b = {
status: 'CONFIRMED'
};
return this.http.put(some_url, b, { headers });
错误:
CORS 策略已阻止从源“http://localhost:4200”访问
【问题讨论】:
标签: angular angular-httpclient