My(assumption) flow is I'll get a form post method html which will contains TOKEN catching it in server side.
app.post('/callback', (req, res)=> {
var token = req.body.access_token
res.cookie('access',token); //instead, i want to set in variable/text field
//res.send('<input type=text name="access_token" value="token" hidden/>')
})
Now, I want to get the token from the variable/text-field from client side which is set by server.
Is it possible to set a value in a text field? (if so, how?)
Is it possible for client side to read a value which is set by the
server side?
Is it a correct process?
If any better process, free to suggest.
Update : I Just wanna try it in Asp.net core
Want to save token in varaible at Controller like
{
if (!string.IsNullOrEmpty(Request.Form["access_token"]))
{
var token = Request.Form["access_token"];
ViewBag.Message = token.ToString();
}
return View();
}
View part :
@{
ViewData["Title"] = "CustomeView";
}
<script>
var message = "@ViewBag.Message";
console.log(message);
</script>
<a href="@Url.Content("/")">Home</a>
After a click on Home link it will redirect to my angular2 index.html
- Index.html - angular 2 ,
How to use
message
(Token Value) variable in angular 2 ?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…