我尝试将POST数据发送到服务器,但是收到错误消息“ net :: ERR_CERT_INVALID”。如下所示的代码是我试图绕过该错误的代码,但仍然失败。请帮忙咨询。谢谢。
import { HttpClient, HttpParams } from '@angular/common/http';
createData(data): Promise<any> {
let post_message = data;
let header_node = {
Accept: 'application/json',
rejectUnauthorized: 'false',
}
// this.oauth_header.Authorization = 'Bearer ' + access_token;
const url_params = new HttpParams()
.set('rejectUnauthorized', 'false')
.set('requestCert', 'false')
.set('insecure', 'true')
return this.http.post('https://ip/createdata', post_message, {
headers: header_node,
}).toPromise();
答案 0 :(得分:0)
尝试将标头作为HttpHeaders
传递到POST
方法。
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
createData(data): Promise<any> {
let post_message = data;
let header_node = {
headers: new HttpHeaders(
{ 'Accept': 'application/json' },
{ 'rejectUnauthorized': 'false' })
};
return this.http.post('https://ip/createdata', post_message, header_node).toPromise();
}