score:0
Accepted answer
try consol logging data.something
like data.id or smthn and when you input the data maybe don't do data.data.attributes.name
i think you can just do data.attributes.name
since you already saved the first data in the state, if this doesn't work show us were you input the data
set data as a dependency in you useeffect to to make useeffect watch for changes in the state
const [data, setdata] = usestate([])
useeffect(() => {
async function getdata() {
var response = await axios.get(`api/admin/category/${category_id.id}`) #changed the link to what you used
setdata(response.data)
}
getdata()
}, [])
console.log('data', data)
}
Source: stackoverflow.com
Related Query
- React Fetch Request returning data is undefined
- Getting undefined when trying to fetch data from an api - React
- How to call a react hook fetch request in a functional component to access data then pass to a class component to map?
- JSON request with React returning undefined
- fetch request with form data for auth react
- return undefined on fetch request inside map react
- Axios request keeps returning twice undefined and twice the data
- Laravel REST API cannot read input data from React Fetch Request
- fetch not returning data in react
- Fetch method returning undefined in React
- React API Fetch Not Returning All Data But Does When Indexing
- Update data from API fetch request with React Hooks?
- Rendering data from fetch request React Native
- Trying to create a fetch request with react hooks, my data is still null
- Fetch request in class component is not returning data or updating state
- Some but not all of fetch data is undefined in React
- React Fetch API Data - Object Undefined
- My browser sends fetch data request continuously and it gives pending status after giving 200 several times in react
- i can see array of objects coming in my http get request from python django but data gets converted into undefined when it comes inside jsx react
- React + Expressjs URL params returning undefined on get request
- React POST form Fetch but Undefined data
- axios and fetch returning empty response data in React
- useState not returning data from fetch request
- React useReducer async data fetch
- How to fetch data when a React component prop changes?
- Where do I fetch initial data from server in a React Redux app?
- How to fetch the new data in response to React Router change with Redux?
- React fetch data in server before render
- REACT fetch post request
- New To React Hook useState Is Returning Undefined
More Query from same tag
- Is there a way to grab the results of a fetch following an onClick event?
- Why React JS function not executing synchronously?
- How to properly unit test a React component?
- Cannot create Store in redux with thunk middlewear
- I want to initialize an array of objects in javascript
- How to make external javascript file work in ReactJs?
- How can I handle the state of a props in the correct method here? It doesn't update
- Unable to add alert notification for the image size validation and its different types format before uploading it how can we implement
- Cannot extract data from post request in node
- Scraping elements rendered using React JS with BeautifulSoup
- How to pass InforProps that extends RouteComponentProps<{ id: string}> in TypeScript
- How do you debug UI state using Immer?
- Error: Too many re-renders. React limits the number of renders to prevent an infinite loop when using useState()
- How I could bind states of an array?
- ReactJS: how can I access parent element width from child component?
- Moving data between react components
- Dynamic react hot reload all js files
- Is there a way to detect the browser permissions(Specifically Camera and Mic) in javascript without prompting for the said Permissions?
- I am having troubles importing a button from React bootstrap
- Target container is not a DOM element, already have div id in the body
- reactjs ,jsx iterate over nested object
- Getting React component instance from ReactDOM.render() return
- How to implement multiple checkbox using react hook
- Removing old versions of create-react-app
- Does graphql support filters on aggregates?
- How to refresh graphql query in parent component after a form is submitted in a child component?
- fix label width to use properly the outlined input
- "Firebase Hosting Setup Complete" after deploy
- React-router v4 route on click Button
- React useReducer bug while updating state array