score:0
if the returned data is intended to be used locally in this component, then what you pass into usestate should match the response you are receiving from the server.
so if for instance your server returns a costomermodel object, you should initiate your usestate with an object -
const [ customer, setcustomer ] = usestate({})
try{
const response = await axios.get<customermodel>(globals.urls.customerdetails)
...
setcustomer(response);
...
}
Source: stackoverflow.com
Related Query
- React - get request using axios not able to setState
- i cant redirect after getting a response using axios post request in react i tried using Redirect but not able to do it
- Express Session Cookie Not Being Set when using React Axios POST Request
- Not able to get the response code in react js axios
- browser says " request has been blocked by CORS policy" when calling to a spring boot get method from react js using axios
- React axios get request without resulting in infinite loop using useEffect
- Not able to set state in React Hooks using data received from Axios
- react js : axios fecth data using a get request condition : i want names with those values with taken: true
- Getting status code 304 on a get request with axios using react and redux
- Error: Objects are not valid as a React child when using axios to get API
- Not able to catch request error using axios
- Making an axios get request and using React useState but when logging the data it still shows null
- react post request using axios is not working properly
- React testing axios get request in componentDidMount using jest
- Get request axios React js useEffect is not working (Cannot find module './undefined')
- too many request on react using axios on get api
- not able to send request to express server using axios
- how to send data in GET request header using react and axios to Django rest framework?
- State not update when using axios get React
- Fill an object (in React js) using results from get request using axios
- Response not rendering from axios get request in react
- Uncaught TypeError: create is not a function using useEffect React Hook with AJAX request
- Axios is caching somehow my get user request react native
- How do I access data returned from an axios get to display on a web page using react js?
- React and Axios GET request issue with Safari on MacOs and iOs
- React axios Error: Request aborted for delete request in Firefox but not in Chrome
- How to properly make a GET call in React returning an observable (resembling the method in Angular and not using promises)?
- Axios get request returns undefined for the first time in React
- Cancel async Axios GET request - React hooks
- React - setState not re-rendering page when Axios call in separate component
More Query from same tag
- Warning: validateDOMNesting(...): <form> cannot appear as a descendant of <form>
- Trouble setting array of object in React state
- Trailing forward slash in react-router routes
- React JSX add min date time to datetime-local input
- React Js : .map is not a function
- How to change main content component based on sidebar component in one layout in React js
- Test call back function sent to a child element using enzyme
- State not being updated in React.js
- How to support optional localisation strings in routes with React-Router
- Exclude a value for a path parameter in React Router by type
- How to trigger React error boundaries when Promises are rejected?
- The state of this element is Undefined for first time?
- React make table clickable and edit details
- "[ts] Unterminated regular expression literal."
- How can I remove the current card?
- React app on gh-pages : can not link to local files
- How to use async await in React component
- react-router-dom TypeScript TS2322: Type 'typeof Index' is not assignable to type
- Conditional Route not rendering the redirected Layout
- react app browser proxy with http-proxy-middleware
- How can I resolve a TypeError where the property of length is undefined, when I have brackets set up to take in a string?
- Spring Boot war or jar for rest api project
- Output ul tags conditionally in JSX?
- Why is webpack code splitting not working for me?
- command to apply changes in react for ubuntu server
- Cannot import react, Uncaught SyntaxError, Unexpected Identifier
- Apply changing markers array to Google map in react
- Are parentheses needed around the returned object in an arrow function in JavaScript?
- Gifted Chat disorganized messages
- Spreading Redux Actions does not work in mapDispatchToProps