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
Post a Comment