Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

144
Vistas
how to use .get() function in a separate JavaScript File

In an exercise for school, there is a website with multiple .js files

The objective of this particular exercise is to get the value of an input field, which is a last name, and compare it to a pre-defined database for autocompletion.

I have to modify file1.js, where I have created a variable that selects the correct input field... I know how to access the string.

Once I have the string, I have to compare it to a known database for any possible Last-name matches... the function is already defined in another file (file2.js), and it looks somewhat like this

server.get("/find_relative/:lastName", (req, res) => {
  let lastName = zahteva.params.lastName;
  findCustomerByLastName(lastName, (error, customer) => {
    if (error) {
      console.log(error);
      res.end();
    } else {
      res.send(customer);
    }
  });
});

I'm not quite sure how to use this function in file1.js, because it's not defined as a variable of any kind... Can anyone help me understand?

Thank you

about 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

It looks to me like your code in file2.js is some kind of Node.js server code. I think you're expected to make a GET request like this (lastName is defined as the URL parameter): localhost:8888/find_relative?lastName=Smith.

For making GET/POST/other requests one standard way is to use the Fetch API.

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda