Answers for "follow and unfollow node js button"

0

follow and unfollow node js button

<% if(isLoggedIn) { %>
                       <% if(user && user._id != currentUser._id) { %>
                       <% const following = user.following;
                          const action = following.includes(currentUser._id) ? 'unfollow' : 'follow';
                       %>
                        <button class="btn btn-primary ml-4" data-action="<%= action %>" data-follower="<%= user._id %>" data-following="<%= currentUser._id %>" id="follow-btn">Follow</button>
                       <% } %>  
                    <% } %>
Posted by: Guest on February-16-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language