每当我请求使用Google API https://maps.googleapis.com/maps/api/geocode/
时我收到此错误
我已经在7号角尝试过了
getHeaderOption(): any {
return { headers: new HttpHeaders({
'Content-Type': 'application/json',
Authorization: 'Bearer ' + this.authService.getToken(),
'Access-Control-Allow-Origin': '*'
})};
}
getPostalCode(address: string) {
this.data = {
address,
};
return this.http.post(environment.mapGeocodeUrl + 'json?address=' + address + '&key=' + environment.mapApiKey,
this.data, this.getHeaderOption()).pipe(catchError(this.handleError));
}
这需要响应结果,但会给出访问控制错误