Nodejs Passport display username in html page

微信扫一扫,分享到朋友圈

Nodejs Passport display username in html page

In nodejs/.ejs
file, I can display the user name as follows:

<% if (!user) { %>
<h2>Welcome! Please <a href="https://www.tuicool.com/login" >Login</a>.</h2>
<% } else { %>
<h2>Hello, <%= user.displayName %>.</h2>
<% } %>

How to do the same in html page.

Problem courtesy of: Narendra Reddy Lingam

Solution

I assume you a static
html page. The short answer is that you can’t– that’s what makes it a static page.

The longer answer is that if you have that html page include some JavaScript that then performs an AJAX call to the server to fetch the username, you can. Look into jQuery $.get
function if you’re choosing this approach.

Solution courtesy of: juanpaco

Discussion

There is currently no discussion for this recipe.

This recipe can be found in it’s original form on Stack Over Flow
.

微信扫一扫,分享到朋友圈

Nodejs Passport display username in html page

CLASSPATH on Mac&comma; and how Mac searches mysql-connector-java-bin&period;jar

上一篇

受疫情影响 Facebook取消了下月在旧金山举办的全球营销峰会

下一篇

你也可能喜欢

Nodejs Passport display username in html page

长按储存图像,分享给朋友