Sorry for my poor choice of wording, but let's say I make a POST request using Axios to an API:axios.post(API_URL, requestData, options).then((response) => {console.log(response.data.result);}, (error) => {console.log(error);});Now, if I understand Async JS correctly, outside of this code block, I can't just say let responseData = response.data.result, because that code will run before the API call is complete and I will get an undefined error.So how can I save response.data.result and basically make use of that data? I want to do all sorts of cool stuff with it.
Submitted June 03, 2020 at 11:44PM by y0ungsinatra
No comments:
Post a Comment