Estoy intentando agregar las reseñas de google maps a mi app de angular y al hacerlo recibo el error: has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
El código que estoy utilizando en mi app es este:
import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
declare var google: any;
@Component({
selector: 'app-referencias',
templateUrl: './referencias.component.html',
styleUrls: ['./referencias.component.css']
})
export class ReferenciasComponent{
ratingDisplay: any;
onRatingSet($event: number) {
throw new Error('Method not implemented.');
}
reviews: any;
constructor(private http: HttpClient) {}
ngOnInit() {
const placeId = 'PLACE_ID';
const apiKey = 'API_KEY';
const url = `https://maps.googleapis.com/maps/api/place/details/json?place_id=${placeId}&fields=name,rating,reviews&key=${apiKey}`;
this.http.get(url).subscribe((data: any) => {
this.reviews = data.result.reviews;
});
}
Obviamente los valores de PLACE_ID y API_KEY ya fueron reemplazados por los correspondientes y mi configuración de credenciales en google esta seteada para que no tenga restricciones. Ya busqué varias soluciones pero no estoy consiguiendo resolverlo.