useEffect( () => {
let allCryptoFuturesSymbols = {}
getOrderRestrictions().then((result) => {
let listOfSymbols = result.symbols
for (let num in listOfSymbols) {
let elt = listOfSymbols[num]
const symbol = elt["symbol"]
Object.defineProperties(allCryptoFuturesSymbols, {
[symbol]: {
value: symbol,
enumerable: true
}
});
})
console.log(allCryptoFuturesSymbols)
console.log(JSON.stringify(allCryptoFuturesSymbols))
}, [])
The output of the first log is correct and expected, and the second is an empty object: {}. If you stringify a manually-defined object there is no problem, but the object created via this for-loop does not behave the same way.