我正在使用Zendesk API并且能够发出发布请求(即使响应告诉我有错误),但我无法使用我的 Angular 4 应用程序和HttpClient发出 GET 请求。
searchZendesk( query : string ) {
console.log(query)
this.search( query ).subscribe(
(data) => console.log(data),
(err) => console.log(err.error),
() => console.log("complete")
)
}
search( query : string ) {
let headers = this.setOptions()
let url = `${ this.baseUrl }/search.json?query=${ query }`
return this.http.get(`${ this.baseUrl }/search.json?query=${ query }`, { headers: headers })
}
setOptions() {
let key = this.setKey()
let headers = new HttpHeaders({
'Authorization': key,
})
return headers
}
打电话后searchZendesk()
我收到以下错误:
No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8100' is therefore not allowed access.