【发布时间】:2019-11-14 21:25:18
【问题描述】:
我正在尝试通过 REST API 服务从服务器获取一些数据。在我下面的 service.ts 中,
getCategories(): Observable<Category> {
// Http Options
const httpOptions = {
headers: new HttpHeaders({
'Content-Type': 'application/json',
'Access-Control-Allow-Origin' : '*',
'Access-Control-Allow-Methods' : 'POST'
})
};
return this.http.post<Category>(this.apiURL+'api', JSON.stringify({"type":"get_categories"}), httpOptions )
.pipe(
retry(0),
//catchError(this.handleError)
)
}
再次显示如下错误,
Object { headers: {…}, status: 0, statusText: "Unknown Error", url: "http://localhost/test/api", ok: false, name: "HttpErrorResponse", message: "http://localhost/test/api 的 Http 失败响应:0未知错误”,错误:错误}
我已经引用了很多帖子,但没有任何帮助。
【问题讨论】:
标签: angular typescript rxjs single-page-application angular8