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

213
Views
nodejs sendFile page rendering with an additional json

I would like to pass into the client - in addition to the html page a JSON

res.sendFile(path.join(__dirname, 'build/index.html'), {aaa: "asdsadaod"});

so I'll be able to do something like this in the html code:

<!DOCTYPE html>
<html lang="en">
  <head>
     <meta charset="UTF-8">
     <title>XXX</title>
     <script>
        const a = "{{aaa}}"
        alert(a)
     </script> 
  </head>
  <body>
     YYY
  </body>
</html>

is it possible ?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

sendFile has no way to do that. It just sends a file.

Instead, pick a template engine and use res.render().

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