httpClient.get调用返回404 Not Found错误

时间:2020-03-20 13:48:56

标签: http

我尝试使用以下代码从localhost:4200获取产品列表...

在一个文件中:

constructor(private http: HttpClient) {} 
getProducts(query: string): Observable<Product[]> { return this.http.get<Product[]>('/api/product'); }

在另一个文件中,我叫上述getProducts(),如下所示:

this.products$ = this.productService.getProducts( "" ); 

错误是这样的:

状态404,statusText:“未找到”,URL:“ localhost:4200 / api / product”。

我不知道如何查询本地主机站点的结构,因此我对如何理解和解决此“未找到”问题感到困惑。

此外,在此之前也存在类似的错误:

zone-evergreen.js:2952 GET http://localhost:4200/api/product 404(未找到)

你能帮我吗?

0 个答案:

没有答案