I have two asynchronous operations. In the interval between them, the result values are not empty and they are used in the next asynron operation. The fact is that one variable with the result falls into the response object from the server, and the second is empty. In this situation: 'frequency' is array, 'lemms' is object.
try {
const pr = new Promise(async (resolve, reject) => {
try {
const { frequency, lemms } = await freqAnalysis(tokenized, lang)
// frequency is visible in this place
const { result, chunks } = await getTesaurusData(frequency)
// but not in this, i get lemms successfully
resolve({ frequency, lemms, result, chunks })
} catch (err) {
reject(err.message)
}
})
const { frequency, lemms, result, chunks} = await pr
const { tesauruses } = formTesaurusData(frequency, result, chunks)
let options = {
res,
result: {
frequency, // empty array
lemms, // good!
tesaurus: {
tesauruses,
totalWords: frequency.length || null,// null
}
},
message: 'success',
statusCode: 200
}
resp(options)