Skip to content

Commit

Permalink
fix(frontend): missing user's information & avatar (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
hbollon committed Aug 18, 2021
1 parent e18dd8f commit 0aec334
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions static/terraboard-vuejs/src/components/Navbar.vue
Expand Up @@ -52,14 +52,14 @@
id="dropdownMenuButton"
data-bs-toggle="dropdown"
aria-expanded="false"
><img src="" height="25px"
><img :src="user.avatar_url" height="25px"
/></a>

<ul
class="dropdown-menu dropdown-menu-end"
aria-labelledby="dropdownMenuButton1"
>
<li><a class="dropdown-item" href="#">Logged in as </a></li>
<li><a class="dropdown-item" href="#">Logged in as {{user.name}}</a></li>
<li>
<a class="dropdown-item" href="/oauth2/sign_in">Sign out</a>
</li>
Expand All @@ -85,7 +85,8 @@ import router from "../router";
options: [],
value: null,
searchable: true,
}
},
user: {}
};
},
methods: {
Expand Down Expand Up @@ -122,8 +123,30 @@ import router from "../router";
.then(function () {
// always executed
});
},
fetchUser() {
const url = `/api/user`
axios.get(url)
.then((response) => {
this.user = response.data;
})
.catch(function (err) {
if (err.response) {
console.log("Server Error:", err)
} else if (err.request) {
console.log("Network Error:", err)
} else {
console.log("Client Error:", err)
}
})
.then(function () {
// always executed
});
}
},
created() {
this.fetchUser();
},
mounted() {
this.fetchStates();
},
Expand Down

0 comments on commit 0aec334

Please sign in to comment.