I'm using a loop to get all whatsapp messages associated with given numbers, using whatsappweb-js. When there is error in this line "let chat = await client.getChatById(nums[i])" I'm not able to catch it , instead I get an error refering to the next line stating that "chat is not defined"! if I remove try catch I don't get any errors but the node js application just stop responding note: client.getChatById(id) return a promise containing chat object.
function fetch(nums) {
    for (let i = 0; i < nums.length; i++) {
        try {
            let chat = await client.getChatById(nums[i])
        } catch (err) {
            console.log(err)
        };
    }
    return msgs = await chat.fetchMessages();
}
 
     
    