Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

138
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda