Loop through don't work?

these code try to loop with every channelID to call messages query, and add all messages in one table, but it feels like it just repeat with one id many times instead of getting messages with each channel ID,any ideas?
const All = [];
Channels.trigger();
const C=Channels.data.channels;

for (var c of C ){
SelectedChannel.setValue(c.sid); //set temp state
Messages.trigger(); //this query auto use temp state as parameter
var M=Messages.data.messages;
if (M!=null){
for (var m of M){
All.push(m);
};};
};

AllMessages.setValue(All);

Hey @Akechi, happy to help! Can I see what Channels.data.channels and Messages.data.messages looks like expanded out in your left panel?

it's a twilio call
channels has a list of
I try to set temp state with each channelID(c.sid)
then call message.trigger() to get messages for that channel
the first loop is to go through every channel and get its messages
second loop it try to get every message and push to All[ ].
it looks like the loop run too fast and doesn't wait.
it changes temp state with the the first loop
when second loop try to run, the first loop has finished
so all get message.trigger are using last channelID many times get data from last id repeatedly .
I am trying to check async queries

this reply to someone is so confusing,reply is in previous post
channel has value, just like the screenshot you showed