我正在尝试使用Google商家信息图API来获取要显示的城市列表。我试图使用自动完成功能来获取我可以解析的JSON。但我收到以下错误:
Failed to load
https://maps.googleapis.com/maps/api/place/autocomplete/json?
input=New&types=(cities)&key=AIzaSyBVgF-ywjsdsWx6JMZNR0UlUL8q67wM5m8:
No 'Access-Control-Allow-Origin' header is present on the requested
resource. Origin 'http://localhost:4200' is therefore not allowed
access.
我有以下作为我的API请求:
searchCities(searchTerm: String) {
const url =
'https://maps.googleapis.com/maps/api/place/autocomplete/json?
input=' + searchTerm +
'&types=(cities)&key=AIzaSyBVgF-ywjsdsWx6JMZNR0UlUL8q67wM5m8';
return this.http.get(url)
.map((response: Response) => {
return response.json();
});
}
我该如何解决这个问题?