Aquí el ejemplo de mi código.
var question = {question: "Q 1. What is your name?", value: "name"}; const getImage = async () => { const image = await GoogleChartsNode.render(drawChart, { width: 400, height: 300, }); fs.writeFileSync("./image.png", image, "binary"); } const drawChart = async () => { const data = google.visualization.arrayToDataTable([ ["Class", "Students", { role: 'style' }], ['5', 1, "color: red"], ['4', 2, "color: orange"], ['3', 3, "color: blue"], ['2', 3, "color: green"], ['1', 1, "color: rgb(152, 240, 149)"] ]); const options = { title: question.question, chartArea: { width: '50%' }, hAxis: { title: "# Ratings", minValue: 0, maxValue: 10 }, vAxis: { title: "# Percentage" } }; }Este es un ejemplo de mi código. Quiero acceder a la pregunta del objeto desde la función drawChart. Pero no es accesible.
Está dando un error como este.
Page error: Error: ReferenceError: question is not defined at drawChart (about:blank:22:12) at drawChartFn (about:blank:38:11) at about:blank:45:24