Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 17e66e2

Browse files
committed
Handle promise rejection
If the request to the api failed the error would not be handled. This meant that the flow would not complete and we wouldn't fall back to the 'en' locale.
1 parent b12bd7a commit 17e66e2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/dashboard/cd-dashboard-projects.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,17 @@
5252
},
5353
methods: {
5454
async loadProjects(locale = 'en') {
55-
const projects = (await ProjectsService.list(locale, { order: 'desc' })).body;
56-
if (projects) {
57-
this.projects = projects.data.slice(0, 3);
58-
}
55+
await ProjectsService.list(locale, { order: 'desc' })
56+
.then((data) => {
57+
const projects = data.body;
58+
if (projects) {
59+
this.projects = projects.data.slice(0, 3);
60+
}
61+
})
62+
.catch(() => {
63+
// If the request fails it is most likely to be the
64+
// locale and we will then fall back to the 'en' locale
65+
});
5966
},
6067
},
6168
async created() {

0 commit comments

Comments
 (0)