title: Can we use async/await in cloud functions in firebase?
body: <p>I have to functions called: getMatchDataApi() and saveApiDataToDb(). getMatchDataApi() function returns value from an api and saveApiDataToDb() function is used to store getMatchDataApi() value into firestore database.</p>
  
  <pre><code>function getMatchDataApi() {
    var options = {
      method: "GET",
      hostname: "dev132-cricket-live-scores-v1.p.rapidapi.com",
      port: null,
      path: "/scorecards.php?seriesid=2141&amp;matchid=43431",
      headers: {
        "x-rapidapi-host": "dev132-cricket-live-scores-v1.p.rapidapi.com",
        "x-rapidapi-key": "63e55e4f7fmsh8711fb1c0bd9ec2p1d8b4bjsne2b8db0a1a82"
      },
      json: true
    };
    var req = http.request(options, res =&gt; {
      var chunks = [];
  
      res.on("data", chunk =&gt; {
        chunks.push(chunk);
      });
  
      res.on("end", () =&gt; {
        var body = Buffer.concat(chunks);
        var json = JSON.parse(body);
        playerName = json.fullScorecardAwards.manOfTheMatchName;
        console.log("player name", playerName);
      });
    });
    req.end();
  }
  </code></pre>
  
  <pre><code>async function saveApiDataToDb() {
    await getMatchDataApi();
    var name = playerName;
    console.log("Aman Singh", name);
  }
  </code></pre>
  
  <p>Here i am using async function. So that first i want it should execute this getMatchDataApi() first and returns the value and after that it should print value inside this function saveApiDataToDb().
  And then i am calling saveApiDataToDb() as follow:</p>
  
  <pre><code>exports.storeMatchData = functions.https.onRequest((request, response) =&gt; {
     saveApiDataToDb()
  });
  </code></pre>