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

113
Views
Why is a the reference of wrapper function still available in the `.then` part of a promise

This following JavaScript snippet works fine:

// generate next extry in order to upadate the
// country html table
app.get('/next', (req, res, next) => {
  data.nextEntry()
    .then(country => tpl.salesForCountry(country))
    .then(html => res.send(html))
    .catch(e => next(e))
})

However, I am asking myself why?

When the get route is called, the Lambda function executes and my custom function nextEntry (it's async) generates a new json object which is then converted to HTML and finally sent back to the requester by calling send of the response object (res).

But why is the reference of res still available and not undefined? Because the Lambda function execution (provided to the get route) has finished long before the HTML has been generated by the then branches. Could somebody kindly point me to the right direction - THX

about 4 years ago · Juan Pablo Isaza
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!