Save Async/Await response on a variable

后端 未结 5 2049
误落风尘
误落风尘 2020-12-24 12:47

I am trying to understand async calls using async/await and try/catch.

In the example below, how can I save my successful response to a variable that can be utilized

5条回答
  •  长发绾君心
    2020-12-24 12:58

    Just use a callback/promise (cascading programming):

    axios(users).then(function(response) {
        const globalData = response;
        console.log(globalData) 
    });
    

提交回复
热议问题