Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(frontend): missing user's information & avatar #204

Merged
merged 1 commit into from Aug 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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