我们有一个REST API,用于一些评论。目前,最有趣的URI是: GET /products/1/comments // get all comments of product 1
GET /products/1/comments/5 // get the 5th comment of product 1
GET /products/1/comments/5/user // ge
我在其中一个组件中获取API,并将其数据发送到dataAPI状态。它工作正常。 但我想开始将我的应用分解成更小的组件。我希望能够从任何其他组件访问数据。而且我不想每次都要做一个不同的API调用。 这是我下面的组件,其中的数据被拉。从应用程序中访问API数据的最佳方式是什么? 我现在还在使用setInterval()来每分钟刷新一次数据。 谢谢! export default class Home