155
rated 0 times
[
158]
[
3]
/ answers: 1 / hits: 53170
/ 7 Years ago, wed, january 10, 2018, 12:00:00
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?
More From » http