如何从php api的React Native中从多维数组获取数据?

时间:2019-02-06 05:59:02

标签: reactjs native

数据:

[ 
  { "flat": 
    [ 
      { 
        "title": "flat", 
        "quote": { 
          "flat": { 
            "code": "flat.flat", 
            "title": "flat", 
            "cost": "5.00", 
            "tax_class_id": "9", 
            "text": "5.00" 
          } 
        }, 
        "sort_order": "1", 
        "error": false 
      } 
    ] 
  }, 
  { "pickup": 
    [ 
      { 
        "title": "pickup", 
        "quote": { 
          "pickup": { 
            "code": "pickup.pickup",
            "title": "pickup", 
            "cost": 0, 
            "tax_class_id": 0, 
            "text": 0 
          } 
        }, 
        "sort_order": "3", 
        "error": false 
      } 
    ] 
  }, 
  { "free": 
  [ 
    { 
      "title": "free",
      "quote": { 
        "free": { 
          "code": "free.free", 
          "title": "free", 
          "cost": 0, 
          "tax_class_id": 0, 
          "text": 0 
        } 
      }, 
      "sort_order": "0", 
      "error": false 
    } 
  ] 
}, { 
  "auspost": [ 
    { 
      "title": "auspost", 
      "quote": { 
        "Courier": { 
          "code": "auspost.Courier", 
          "title": "Courier", 
          "cost": "246.65", 
          "tax_class_id": "9", 
          "text": "246.65" 
        }, 
        "Express": { 
          "code": "auspost.Express", 
          "title": "Express", 
          "cost": "196.65", 
          "tax_class_id": "9", 
          "text": "196.65"
         }, 
         "Standard": { 
           "code": "auspost.Standard", 
           "title": "Standard", 
           "cost": "185.65", 
           "tax_class_id": "9", 
           "text": "185.65" 
          } 
        }, 
        "sort_order": "0", 
        "error": "" 
      } 
    ] 
  } 
]

1 个答案:

答案 0 :(得分:0)

使用axios进行任何API调用

参考:https://alligator.io/react/axios-react/