javascript - Get headers on page load from node-express app? -


i building app node , express , set such when page loads, headers sent client. how extract information on client side? using js/jquery on client side. here's code in question-

app.get('/', (req, res) => {   models.game_session.build({     sid: req.sessionid   }).save().then((data) => {     let options = {       "root": __dirname,       headers: {         "x-sid": data.id       }     }     res.sendfile('/index.html', options, (err) => {       if (err) {         res.send(err)       }     });   }).catch((e) => {     res.send(`there error`);   }); }); 

i saving session id in database sending index file client. see in options object, want include session id in header sent index file. how can retrieve info on client side? i'm not sure if going in right way- appreciate help!

edit: sorry, didn't read closely enough. it's not possible, , here's why:

https://stackoverflow.com/a/220233/4045156

what doing fine, (once page loads on client side) make request server , respond simple json object. it's totally though. of course means request, doesn't seem possible avoid request anyways.


Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -