【问题标题】:i have data in my shopify api i want to use that data in my reactjs app how do i do that我的shopify api中有数据我想在我的reactjs应用程序中使用该数据我该怎么做
【发布时间】:2022-01-25 22:25:00
【问题描述】:

数据是这样的 我只想在列表中显示标题和评分 api 是这样的 = {apikey}{password}@{shopname}.myshopify/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 }, 
           ]
}

【问题讨论】:

    标签: html css reactjs api shopify


    【解决方案1】:

    我假设您正在向 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。

    【讨论】:

    • 是的,谢谢,但我想知道我可以从 react js 中的 shopifys admin api 获取数据,因为我有那个 admin api,但我无法从中获取数据
    • 首先需要查看endpoint是否真的存在并且可以使用。使用邮递员并尝试一下..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-02-21
    • 2011-08-12
    • 2023-03-27
    • 1970-01-01
    • 2011-04-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多