score:2
Accepted answer
So in order to await signup()
in handleSubmit
, the signup
function itself needs to return a promise. eg
function signup(name, e, p) {
return axios
.post("/register", {
username: name,
email: e,
password: p,
})
.then(function (response) {
console.log(response.data[0]);
return response.data[0]; //"dear user, please check etc..."
});
}
Source: stackoverflow.com
Related Query
- How to update the React State only after a return from API called is completed
- React JS (Form Update Not Working) - How to set state immediately after getting data from API using mapDispatchToProps?
- How to instantly update react state after replacing the value from array
- How to update the state of a sibling component from another sibling or imported component in REACT
- How do you update Formik initial values with the react context api values after an AJAX request?
- How can I make a request to an API based on the response from another request? React Hook "useSwr" cannot be called inside a callback
- How to update the state after a data update through an API request in React?
- How do I correctly add data from multiple endpoints called inside useEffect to the state object using React Hooks and Context API?
- How to fix the state update in react while getting data from firestore database
- How to update redux state using a react variable passed up to the component from a child
- React - how to update state from the prop of other library
- How can I update the state from an API call?
- update react child component's state using props received from an async api call made in the parent component
- how to update nested state array and then return the entire array react
- How to set the data from my API as initial state for my react component?
- How do I make an axios request using a route parameter from React Router, then update state based on the response?
- How do I keep the state of a React Component after removing others from an array?
- How to change only a part of the state from child component react hooks
- How to clear input text box, after obtaining the result from API in React
- How to set state at the server for data from API using react redux
- How to update state array fetched from API in React Hooks?
- How to store the data in React state after Querying it from GraphQL?
- How to add objects retrieved from fetch request to the state array in React and then update the view?
- How we can update the state of button to logout after successfull login in react redux
- Cant Update The state after getting data from the input React js
- How to set the initial state value after fetching data to update a form in react
- react (class based) : How can I update JSON object in parent component using setState after the object being passed in function from child to parent?
- React - How can I wait for the UI to update after multiple api calls?
- How to update state of child component when it get called in map function from parent component React JS
- How to update state of the component with data from API
More Query from same tag
- react-router Switch and 404 page
- Change the file format using browser-image-compression library in reactjs?
- React reducer giving error
- How to make clickable text in Reactjs?
- error: "User.findOne is not a function" in MERN
- How to write React Styled Component property that requires two lines?
- Unit testing entry file in React
- What's the way to show the cointop 50 in webpage?
- Create dynamic route using list of string as paths in React JS with BrowserRouter
- How to mock a method from a functional component in React using jest and Enzyme
- Async Autocomplete does not show options when label keys are different from filtering keys
- How to refactor React mousemove Class to functional Component?
- React setting state with async/await
- React axios request asks for UseEffect cleanup function to cancel all subscriptions and asynchronous tasks
- How to run one 'npm start' for two different folders in my project directory
- Running a React/Rails app locally
- Define callback ref TypeScript and react-slick library
- ReactDOM.render but using a class
- React JS: ability to detect switching tab in browser
- Adding styled component to bootstrap modal which is outside of usual class wrapper and called via ajax
- How do I sustain data from DB while using another GET request with different query string in React(Next.js)?
- Need help for loop in React
- componentDidMount seems not to be called after setState in ReactJS
- Putting switch case inside map function
- React setState based on the current state
- Image is not showing in page using react
- React using JS var inside quotes
- Super expression must either be null or a function, not undefined when using React-Sparklines
- How to fill in a table in react with an array of objects?
- react-datepicker input width will not adjust to 100%