Angular 8-httpClient的Get方法转换为Options方法 [英] Angular 8 - httpClient Get method transforms to Options method
本文介绍了Angular 8-httpClient的Get方法转换为Options方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将Get请求发送到我的服务器(Microsoft 2012).我已经添加了
I am trying to send Get request to my server(Microsoft 2012). I have already added this solution. But in this is solution my get request transformed to Options method.
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/vnd.sas.datamgmt.jobflow.metadata+json; charset=utf-8',
'Authorization': 'Basic' + btoa('username:password')
})
};
我还添加了:
httpOptions.headers.set('username', 'password');
httpOptions.headers.append('Access-Control-Allow-Origin', '*');
httpOptions.headers.append('Access-Control-Allow-Credentials', 'true');
httpOptions.headers.append('Access-Control-Allow-Methods', 'GET,POST,OPTIONS');
this.typesOfDBs = this.http.get<Info[]>(this.ROOT_URL, httpOptions);
我查看了我的请求,发现该请求现在是选项"请求.如何处理它并以Get方法发送请求?
I watched my request and I saw the request is now Options request. How can I handle it and send request as Get method?
推荐答案
我使用nodejs代理来解决此问题.Nodejs可以轻松处理它.您必须从angular向Node.js发送请求.并从nodejs到restapi.
I used nodejs proxy to solve this question. Nodejs handled it easily. You must send request to nodejs from angular. And to restapi from nodejs.
这篇关于Angular 8-httpClient的Get方法转换为Options方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文