angularjs - Is there a way to both redirect and send json in express? -


i have registration functionality sends confirmation email user in application, , want similar following:

return res.status(200).redirect('/').json({   message: 'successfully confirmed account!' }); 

i knew wouldn't work, think demonstrates want. using angularjs, why need render json client. how best accomplish this?

there isn't way have browser somehow forward response body data across request. there multiple ways achieve you're trying do:

  1. simplest way: send message query string argument. of course enables craft urls messages, might want validate or pass key , message based on that.
  2. use session , put message in there. delete after it's been shown. these called "flash messages".
  3. you set flag in database this, seems bit overkill have entire field show message.

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -