Edit Fork Copy async function getChomSao() { sao = ['ma-ket', 'bao-binh', 'song-ngu', 'bach-duong', 'kim-nguu', 'song-tu', 'cu-giai', 'su-tu', 'xu-nu', 'thien-binh', 'bo-cap', 'nhan-ma']; len = sao.length; for (i = 0; i < len; i++) { for (j = 0; j < len; j++) { let url = `https://maudon.com/boi_tinh_yeu_cung-${sao[i].replace('-','_')}-${sao[j].replace('-','_')}.jsp`; await axios.get(url).then(async res => { content = res.data; content = (content.match(/(.|[\n\r])+(.|[\r\n])+<\/p>(.|[\r\n])+/g))[0]; content = content.match(/(.|[\r\n])+<\/p>/g)[0]; await connection.query(`INSERT INTO cung_hoang_dao(id, male, female, content) VALUES(NULL, '${sao[i]}', '${sao[j]}', '${content}')`, await function (error, results, fields) { if (error) throw error; console.log('The solution is: ', sao[i], '--', sao[j]); }); }); } } } getChomSao();