Thursday 27 December 2018

Sending data onto the client after authentication using express.

This may seem like a nooby question... But it's a scenario I've not yet encountered.Normally when I write my server code it's responsive, in that it simply replies to user requests. But this is different.I have a callback endpoint that will extract an access token. The problem I'm facing is that because the user never makes a get request, and that wouldn't really work even if they did, I don't know how to correctly send across and receive that token on the client side.So I can do a res.send() and that will send the token information to the user to be automatically rendered on the page. It's not what I want, however. I want the client to get the access token, but not display anything automatically. I suppose I could use res.sendFile() but this and res.json() both bring me to this problem:How do I listen for these? Since I'm not fetching and using a .then(responsedata), how do I get the response?​tl;dr: how can I send data to client without fetching it or displaying it with res.send().

Submitted December 27, 2018 at 03:54PM by HUMBLEFART

No comments:

Post a Comment