how can i display an element if a user is logged in in vuejs

Issue

This Content is from Stack Overflow. Question asked by jibzy

i’m trying to display this div tag when a token is stored in my browser

 <div>
<h4>hello</h4>
 </div>

i get token in my browser

eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI2MzA3NjZmZDM2MGI4NDBmMmYxMmQzYzEiLCJuYW1lIjoidG9sdSIsImVtYWlsIjoidG9sd```

this is my script tag


<script>
export default {
  name: "app",
  components: {},
  data() {
    return {
    };
  },
  mounted() {
    const token = localStorage.getItem("token")
  },
 
};
</script>

please how can i go about this



Solution

Check the Answers

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?