sugestion.on('collect', a => {
const Suggestion = a.content;
});
console.log(`Suggestion: ${Suggestion}`);
I'm with TypeError with the above code.
(node:4872) UnhandledPromiseRejectionWarning: ReferenceError: Suggestion is not defined
sugestion.on('collect', a => {
const Suggestion = a.content;
});
console.log(`Suggestion: ${Suggestion}`);
I'm with TypeError with the above code.
(node:4872) UnhandledPromiseRejectionWarning: ReferenceError: Suggestion is not defined
You are trying to reference a variable out of scope. The variable Suggestion
only exists within the scope of the function (a=>{}
). Either move the console.log
line into the function, or save the value in another variable outside the scope, for future reference.
You need to have the Suggestion variable in scope
let Suggestion;
sugestion.on('collect', a => {
Suggestion = a.content;
});
console.log(`Suggestion: ${Suggestion}`);