Skip to content

Commit 53ff1b6

Browse files
committed
Auto merge of #2465 - Turbo87:async-await, r=locks
Use async/await for `model()` hooks instead of Promise chains r? @locks
2 parents 3486fe6 + 72268b8 commit 53ff1b6

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

app/routes/category.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import { inject as service } from '@ember/service';
44
export default Route.extend({
55
flashMessages: service(),
66

7-
model(params) {
8-
return this.store.find('category', params.category_id).catch(e => {
7+
async model(params) {
8+
try {
9+
return await this.store.find('category', params.category_id);
10+
} catch (e) {
911
if (e.errors.some(e => e.detail === 'Not Found')) {
1012
this.flashMessages.queue(`Category '${params.category_id}' does not exist`);
1113
return this.replaceWith('index');
1214
}
13-
});
15+
}
1416
},
1517
});

app/routes/keyword.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import { inject as service } from '@ember/service';
44
export default Route.extend({
55
flashMessages: service(),
66

7-
model({ keyword_id }) {
8-
return this.store.find('keyword', keyword_id).catch(e => {
7+
async model({ keyword_id }) {
8+
try {
9+
return await this.store.find('keyword', keyword_id);
10+
} catch (e) {
911
if (e.errors.some(e => e.detail === 'Not Found')) {
1012
this.flashMessages.queue(`Keyword '${keyword_id}' does not exist`);
1113
return this.replaceWith('index');
1214
}
13-
});
15+
}
1416
},
1517
});

0 commit comments

Comments
 (0)