Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

async wait for axios reactjs

useEffect(() => {
  async function fetchData() {
    // You can await here
    const response = await MyAPI.getData(someId);
    // ...
  }
  fetchData();
}, [someId]); // Or [] if effect doesn't need props or state
Source by thewebdev.info #
 
PREVIOUS NEXT
Tagged: #async #wait #axios #reactjs
ADD COMMENT
Topic
Name
6+2 =