I'm trying to write a code about GTFS with node-fetch. When I use the promise, It can return values but when I try to add them into an array for information filtering purposes. The system returned undefined values. What can I do with this situation?
function getStopInfo(StopId){
mta.schedule(StopId).then(function (result) {
console.dir(result, {depth:null, colors:true});});
}
global.info = getStopInfo('627');
global.a = Array(20).fill(info);
console.log(global.a);
Here are the return values:
[ undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined,
undefined ]