Effectively, I'm running a for loop over a list of strings that are used as parameters for a function called getPrices. getPrices is a fetch request to an API, so I make sure to put a .then statement on it in order to get the result. That result gets fed into another function (which has no asynchronous features) called "oneDay". I'm trying to store each result from oneDay in a dictionary called "priceDict" with the key being the string parameter during that current loop. The problem is, no matter how I configure the .thens, I can't seem to store anything except promises in the dictionary.
This code snippet, after being run, only gives me an array of promises for priceDict:
var priceDict = {};
for (const position of setPositions) {
let positionFormula = function (somePosition) {
return getPrices(somePosition).then((data) => {
return oneDay(data, start, today, interval);
});
};
let someBullshit = positionFormula(position);
priceDict[position] = someBullshit.then(function (result) {
return result;
});
}
console.log(priceDict);
How can I make it so that priceDict is actually the result as opposed to just the promise objects?