I'm currently trying to use async/await for a function that requires the loop to be synchronous.
This is the function:
async channelList(resolve, reject) {
let query = ['channellist'].join(' ');
this.query.exec(query)
.then(response => {
let channelsRaw = response[0].split('|');
let channels = [];
channelsRaw.forEach(data => {
let dataParsed = ResponseParser.parseLine(data);
let method = new ChannelInfoMethod(this.query);
let channel = await method.run(dataParsed.cid);
channels.push(channel);
});
resolve(channels);
})
.catch(error => reject(error));
}
When I try to run it, I get this error:
let channel = await method.run(dataParsed.cid);
^^^^^^
SyntaxError: Unexpected identifier
What could be the cause of it?
Thanks!