简体   繁体   English

为什么我的地图功能无法在浏览器上显示 API 数据?

[英]why my map function is not working to display API data on browser?

I am getting the data in console but, unable to find the correct path to map over data in nested map functions.我正在控制台中获取数据,但是无法找到在嵌套映射函数中映射数据的正确路径。 I want an Image component for every product in array.我想要数组中每个产品的 Image 组件。 控制台中的 API 数据

I am trying this path to map over object given below in picture.
This is the query having async function that fetched the data.

   const res = useCategoriesQuery({
     type: query.type,
     text: query?.text,
     category: query?.category,
      });
     console.log(res);

地图功能

The Error I am getting is -我得到的错误是 - 错误

您必须映射data

res.data?.categories.data.map()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的 map() function 在 react.js 中不起作用? - Why is my map() function in react.js not working? map function 不适用于 useEffect 中的 API 数据 - React Hooks - map function not working for API data in useEffect - React Hooks 为什么上下文 api 提供的我的设置器 function 在句柄 function 中不起作用 - Why is my setter function provided by the context api not working in the handle function 我 console.log 数据并显示在控制台上。 但它没有在浏览器上显示数据。 这是说 events.map 不是 function - I console.log the data and it display on console. But it didn't display the data on the browser. It's saying events.map is not a function 数据map function在Reactjs不工作 - Data map function is not working in Reactjs 为什么 data.map 不是 function? - Why is data.map not a function? 类型错误:尝试显示来自 API 的数据时,无法在我的 React 应用程序中读取未定义的属性“映射”错误? - TypeError: Cannot read property 'map' of undefined' error in my React application when trying to display data from an API? 从 API 获取和映射中反应显示数据 - React Display Data from API Fetch & Map 为什么我的端点的数据不会在成功的身份验证后显示在浏览器上? - Why won't my endpoint's data display on the browser on successful auth? 如何在 React 中使用 fetch 和 map function 显示包含字符串的 POST API 数据 - How to display POST API data containing string using fetch and map function in React
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM