reactjs – React.js vs Javascript variable declaration

I have here a code using React.js, this code returns undefined in the console..

getTicket = async() =>{
    var ticketData;
        await function(data){
            ticketData = data['ticket'].toString();
    await this.setState({ ticketInformation: ticketData })

while this one is javascript, this code returns the value of ticketData..

  var ticketData;
    function(data) {
      ticketData = data['ticket'];
      console.log("TICKET:: " + JSON.stringify(;

my question is, what is the difference between the 2? on the first code as you can see, I am using a async/await which should not return undefined as far as I know.. Somehow the 2nd code has no async/await but fully giving a value to the global variable.

Read more here: Source link