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

137
Views
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 answers
Answer question

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 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!