我在我的React Native上使用节列表,问题是节列表接收这种数据。
const DATA = [
{
date: "Main dishes",
data: ["Pizza", "Burger", "Risotto"],
},
{
date: "Sides",
data: ["French Fries", "Onion Rings", "Fried Shrimps"],
},
{
date: "Drinks",
data: ["Water", "Coke", "Beer"],
},
{
date: "Desserts",
data: ["Cheese Cake", "Ice Cream"],
},
];
但是我的API只能发送这种数据
const DATA = [
{
date: "Main dishes",
data: {
items: ["Pizza", "Burger", "Risotto"]
},
},
{
date: "Sides",
data: {
items: ["French Fries", "Onion Rings", "Fried Shrimps"]
},,
},
];
问题是,我的节列表不适用于此,因为数据不是数组,而是对象。
有人知道我该怎么做吗?
非常感谢你的帮助!!
1条答案
按热度按时间ix0qys7i1#
您可以尝试将接收到的数据序列化为: