tengo una función en la que devuelvo algún elemento html, antes de devolverlo, si consola. log (), genera el valor numérico, por ejemplo. 1234... sin embargo, su tipo de () es "objeto" a pesar de que lo he analizado flotante ()... después de devolverlo, regresa como un tipo de () como función... estoy tratando de pasar el valor devuelto a otro función, ¿alguien puede explicarme qué está mal? ¿Cómo mantengo el valor de retorno como un objeto o flotante en lugar de una función para poder pasarlo?
async function checkPrice(page) { await page.reload(); await page.waitForNavigation(); await page.waitForTimeout(2000); // network idle2 not working... this is sufficient var html = await page.evaluate(() => { const buyTag = document.querySelectorAll(".MuiButton-root.MuiButton-contained.MuiButton-containedPrimary.MuiButton-sizeMedium.MuiButton-containedSizeMedium.MuiButton-disableElevation.MuiButtonBase-root.color-tertiary.css-k5syhx .css-gmuwbf"); let prices = []; buyTag.forEach((tag) => { if(tag.innerHTML[0] === '$' ) { var string = tag.innerHTML; var float = parseFloat(string.replace(/[^0-9.-]+/g, '')); if(prices.length < 1) { prices.push(float) }} }); return prices }); // console.log(html) returns 1234, typeof() is obj here return html } // console.log(html) returns a function here async function priceUpdate(html) { let new_price = []; let old_price = []; if(new_price.length < 1) { new_price.push(html); } if(new_price.length > 0) { old_price.pop(); old_price.push(new_price); new_price.pop(); new_price.push(html); } if(parseFloat(new_price[0]) != parseFloat(old_price[0])) { console.log('lowest price changed from: $' + old_price + ' to: ' + '$ ' + new_price); } else { console.log('current price: $' + old_price); }; } async function monitor() { let page = await configureBrowser(); for(var i=0; i=1000; i++) { await checkPrice(page); await priceUpdate(html); }} monitor()