score:3
Accepted answer
You're using await
with then()
. You should switch to one. If you use await, assign the result to a variable. You should also be passing back the data of the response and not the response itself.
const response = await axios.post(...)
callback(response.data)
If you want to use then
, then it's:
axios.post(...)
.then(respone => callback(response.data))
Source: stackoverflow.com
Related Query
- axios.post().then() not passing resolved data to callback function
- req.params not passing from React frontend to serverless function on Axios post request
- passing data from child to parent component - react - via callback function
- Sending state for an Axios POST and data not showing in req.body
- useState not updating data when passing from parent function component using ref
- How to send data as string and not json on axios post
- Axios post does not send data
- Map is not a function when passing data to populate child component
- Axios callback function not working in put method
- React axios post request does not send the data
- Passing secondary data to my second callback function
- TypeError: language.map is not a function when getting data using axios
- How do I see why Axios POST request is not sending payload data to Heroku Backend?
- pages.map is not a function in gatsby nodejs using axios to fetch data
- Then and Catch not running on successful Axios Post request on Backend
- Axios post not passing body parameters
- Passing a function as a callback to a React state created with hooks did not reflect new value of variable
- POST request with Axios not sending data to my server
- React .map function not passing data to useState
- Axios POST does not recognize the data being passed in from react
- Passing a function to React Component and then calling it causes "Uncaught TypeError: x is not a function"
- React typeerror in axios callback TypeError: this.setState is not a function
- React : Callback value received in parent not passing the latest value in another child as prop | Function component
- Function not defined while passing child data to parent
- Uncaught (in promise) TypeError: data.map is not a function (React using axios getting data from ASP.NET API)
- React.js - How do I pass data from a div to a function with axios POST method?
- Why does ASP.NET Core 6 MVC Route handler not accept data from axios post request?
- not able to receive axios data sent via post method at my backend
- Component not remounting after passing axios request data
- Api call to post data not working with either fetch or axios
More Query from same tag
- Unable to edit form fields in Reactjs after fetched from server
- Cannot read properties of undefined (reading 'DateTime') even I check there is a data in React.js
- How can I use an IIFE in the return function of a react component?
- Alter inline css with react issue
- Link in react-router-dom removing css
- React Functional Component - useState / useCallback - value changes back / reverts to initial value on submit
- How to pass function from class parent component to child functional component
- How to move Cancel button to the right in IonSearchbar in Ionic React
- How to deploy Django/React/Webpack app on Digital Ocean through Passenger/Nginx
- How to add default value to react creatable skills
- How can I give a key in JSX the value of a variable depending on conditions
- React-Native fetch, Network request failed. Not using localhost
- How to run my react app in Docker container
- JavaScript Arithmetic's
- React: Name not coming through onChange(), e.target.name is undefined on DatePicker
- How to style a ButtonGroup so it doesn't change the form's width with the addition more names in React?
- AutoComplete Material UI getOptionSelcted warning
- Translating React + Axios from Javascript > Typescript
- ReactDOM is not defined ( but from within a React method )
- REACTJS _ eventListener - Why my event listener trigger several times?
- Incrementing state in useEffect sometimes result in a wrong state
- CORS issue in ReactJS
- Function does not work on first render instead the series is generated after the subsequent renders
- How to type extended styled-component?
- How can I get the value of a select form element?
- useCallback Implementation
- Getting ERROR in React JS: SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data?
- React app detect if user refresh window or navigated away
- Is passing "props" outside of the props object an anti-pattern?
- How to render different data on dropdown selection using Material's UI Select?