I'm trying to perform a get request using the following:
router.get('/marketUpdates',((request, response) => {
  console.log("market updates");
  var data: Order[]
  axios.get('http://localhost:8082/marketUpdates')
  .then(function (response) {
    console.log("GET Response")
    console.log(response.data);
    data = response.data;
  })
  .catch(function (error) {
    console.log("Error in fetching market updates");
  });  
  console.log("Data before sending is ")
  console.log(data);
  response.send(data);
}))
However, my console.log near the bottom gets executed before the console.log in .then.
data is undefined when it is being sent. Does anyone know how I can avoid this?
 
     
    