我尝试使用以下代码从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(未找到)
你能帮我吗?