如何将对象的对象转换为对象数组
我正在获取一个API端点,该端点以格式返回数据
{
"0": {
"name": "Rohan"
},
"1": {
"name": "Meghan"
},
"2": {
"name": "Rita"
}
}
,但是由于它不是数组,我的地图函数会引发错误,
Home.jsx:39 Uncaught TypeError: users.map is not a function
因此我想将对象的对象转换为const arrofarr
。阵列应该看起来像:
[
{
"name": "Rohan"
},
{
"name": "Meghan"
},
{
"name": "Rita"
}
]
I am fetching an API endpoint which returns data in the format
{
"0": {
"name": "Rohan"
},
"1": {
"name": "Meghan"
},
"2": {
"name": "Rita"
}
}
But since it is not array my map function throws an error
Home.jsx:39 Uncaught TypeError: users.map is not a function
Hence I want to convert this object of objects into a const arrOfarr
. The array should look like:
[
{
"name": "Rohan"
},
{
"name": "Meghan"
},
{
"name": "Rita"
}
]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过此行获得键和价值对。
You can get key and value pairs with this line.