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

99
Views
Passing data from server to client script

I have an express.js app using with Jade. I'm trying to read information from the server on the client however I keep getting errors.

router.js

res.render('index', { title: 'cooltitle'})

index.jade

script(src='/javascripts/index.js')
h1=title
script(type='text/javascript').
    var data = !{title}
    console.log(data)

h1 correctly shows the title: 'cooltitle' in the browser. But trying to read the data in the javascript results in the following errror Uncaught ReferenceError: cooltitle is not defined at (index):1:298

Also is there a way to get the title object from the index.js? i get the following error: Uncaught ReferenceError: title is not defined at main.js:2:13

index.js

console.log(title)
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!