我的shopify api中有数据,我想在我的reactjs应用程序中使用这些数据,我该怎么做



数据如下我只想在列表中显示标题和收视率,仅此而已api是这样的={apikey}{password}@{shopname}.myshopiy/admin/api/{api version}/{resource.json}

{ 
"orders": [
{ "tittle" : "name 1", "rating": 5 }, 
{ "tittle" : "name 2", "rating": 3 }, 
{ "tittle" : "name 3", "rating": 1 }, 
{ "tittle" : "name 4", "rating": 2 }, 
]
}

我假设您正在向api发出请求,因为您几乎没有提供任何信息。

const[orders,setOrders]=useState((;

ApiRequest.then((res(=>setOrders(res.orders(((为您的api响应创建状态(

<ul>
{orders.map((order) => <li> Title: {order.title}, Rating: {order.rating} </li>)}
</ul>

通过映射结果数组将响应渲染到JSX中。

最新更新