Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

149
Views
cómo pasar el parámetro de una función de página a otra función de clase de página en Javascript / Node js

Quiero pasar el parámetro de mi página app.js a otra página User.js que contiene la función de clase, pero todo lo que obtengo es un valor undefined . Estoy tratando de pasar la opción seleccionada del encuestador pero no se pasa.

Usuario.js

 class User{ setUser(name){ let userThing= fname(name); ... ... return userThing } getUser(){ ... ... return } } module.exports.User=User;

aplicación.js

 const { Command } = require("@oclif/command"); const inquirer = require("inquirer"); const config = require("./User.js"); class RegionCommand extends Command { async run(){ inquirer .prompt({ type: "list", name: "test", message: " Select Nickname: ", default: false, choices: ["Tom", "Jerry"], }) .then((answers) => { var selectedName=answers.test; // var nameDetails= this.config.User.setUser(selectedName); I tried this method too but still not working. var nameDetails= config.User.setUser(selectedName); }); } }

¿Cómo puedo pasar mi valor de consulta app.js a user.js?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Está intentando llamar a una función normal como una función estática. ¡Primero necesitas crear una instancia de clase!

 const { Command } = require("@oclif/command"); const inquirer = require("inquirer"); const { User } = require("./User.js"); class RegionCommand extends Command { async run(){ inquirer .prompt({ type: "list", name: "test", message: " Select Nickname: ", default: false, choices: ["Tom", "Jerry"], }) .then((answers) => { var selectedName=answers.test; const user = new User(); // create an instance of the class "User" var nameDetails= user.setUser(selectedName); }); } }
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!