How to wait for API response to return component?
I am building a page component that returns data from an API call and passes the values to my return statement. My page continues to return as blank because the page loads before the variables are returned from the API. How can I wait to render the page until my API has returned a response? The two variables are initialized as so and are not updated until the API response: var userData const [customer_email, setEmail] = useState(); const [newuserid, setUserId] = useState(); useEffect(() => { userData = Cookies.get("user-data"); if (userData) { console.log("Userdata !== null"); try { userData =
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.