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

102
Visualizações
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
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