我使用第三方服务来获得请求的某些响应。我得到的响应是一个json数组,但我无法获取它的特定详细信息。
const dispatchListColumns = [
{
dataField: 'id',
text: 'id',
sort: true,
formatter: (cell, row) => {
return (row)
}
},
{
dataField: 'tel',
text: 'Telephone Number',
sort: true,
formatter: (cell, row) => {
return (row)
}
},
];
这是我在表中的列,当我返回“行”时,它的响应为:
["[{"_id":"5d709d18e148b95aeccde88d","tel":"95604535…,"tripId":"5d6e3631a07e4e6f69199490","address":"S", "hop No.66, Main Road shalimar, Block BH, Sahipur V… 110088, India","distance_remained":363605,"time_", "remained":22003,"curr_ETA":"2019-09-08T08:17:07.43…":"2019-09-05T05:28:56.424Z"},{"_id":"5d7072d1e14", "8b95aeccdc004","tel":"9560453585","loc":[28.713564…a07e4e6f69199490","address":"BG/9, Rajender Singh", " Sehrawat Marg, Block BG, Shalimar Bagh, Delhi, 11…ed":364080,"time_remained":22056,"curr_ETA":"2019", "-09-08T05:22:36.683Z","city":"Delhi","createdAt":"…_id":"5d70488ae148b95aeccd9595","tel":"9560453585", "","loc":[28.713564,77.16004],"tripId":"5d6e3631a07…9, Rajender Singh Sehrawat Marg, Block BG, Shalim", "ar Bagh, Delhi, 110088, India","distance_remained"…,"curr_ETA":"2019-09-08T02:32:59.230Z","city":"De", "lhi","createdAt":"2019-09-04T23:28:10.632Z"},{"_id…"tel":"9560453585","loc":[28.713478,77.16007],"tr", "ipId":"5d6e3631a07e4e6f69199490","address":"BG/16,…hi, 110088, India","distance_remained":364961,"ti", "me_remained":22078,"curr_ETA":"2019-09-07T23:32:43…dAt":"2019-09-04T20:27:47.986Z"},{"_id":"5d6ff3fd", "e148b95aeccd3caf","tel":"9560453585","loc":[28.718…631a07e4e6f69199490","address":"Chaudhary Meher C", "hand Yadav Marg, Block BC, Beri Wala Bagh, Shalima…,"distance_remained":364919,"time_remained":22036", ","curr_ETA":"2019-09-07T20:31:49.684Z","city":"Del…7:27:25.507Z"},{"_id":"5d6fc9c6e148b95aeccd1200",", ""tel":"9560453585","locand ":[28.720737,77.16147],"tri…0","address":"195, Shalimar Bagh Azapur Mandi Rai", "lway Under Bridge, Mutiny Memorial, Azadpur, Delhi…mained":363410,"time_remained":21746,"curr_ETA":"", "2019-09-07T17:13:04.801Z","city":"Delhi","createdA…}]
这就是我将数据传递给它的方式:
<CardHeader>
<b>Loading Plan</b>
</CardHeader>
<div>
<DataTable columns={dispatchListColumns} data={plan}/>
</div>
</Card>
这是我的API调用:
const [data, setData] = useState([]);
const [plan, setPlan] = useState([]);
useEffect(() => {
const getTrucks = async () => {
refreshing();
const truckData = await assignedTrucks();
setData(truckData);
console.log(truckData, "truck")
};
const getLoacation = async () => {
const locationPlan = await trackNow();
setPlan(locationPlan);
console.log(locationPlan, "locationPlan");
};
getTrucks();
getLoacation();
},[assignedTrucks],[trackNow]
);
现在可以说我想从此数据中获取ID和地址的详细信息,因为我已经尝试过row._id
和row.address
,但是在控制台中却得到了Undefined,我现在被所有问题困在这里这些细节。