Skip to content

Commit c27aeb9

Browse files
committed
Use async/await in the then clause to make code more readable.
1 parent 90dffbf commit c27aeb9

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

src/grafana.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ module.exports = (robot) => {
9494
title = `Dashboards tagged \`${tag}\`:\n`;
9595
}
9696

97-
service.search(null, tag).then((dashboards) => {
97+
service.search(null, tag).then(async (dashboards) => {
9898
if (dashboards == null) return;
99-
return sendDashboardList(dashboards, title, context);
99+
await sendDashboardList(dashboards, title, context);
100100
});
101101
});
102102

@@ -108,10 +108,10 @@ module.exports = (robot) => {
108108
const query = msg.match[1].trim();
109109
robot.logger.debug(query);
110110

111-
service.search(query).then((dashboards) => {
111+
service.search(query).then(async (dashboards) => {
112112
if (dashboards == null) return;
113113
const title = `Dashboards matching \`${query}\`:\n`;
114-
return sendDashboardList(dashboards, title, msg);
114+
await sendDashboardList(dashboards, title, msg);
115115
});
116116
});
117117

@@ -160,11 +160,11 @@ module.exports = (robot) => {
160160
const paused = msg.match[1] === 'pause';
161161
const alertId = msg.match[2];
162162

163-
const message = service.pauseSingleAlert(alertId, paused);
164-
165-
if (message) {
166-
msg.send(message);
167-
}
163+
service.pauseSingleAlert(alertId, paused).then((message) => {
164+
if (message) {
165+
msg.send(message);
166+
}
167+
});
168168
});
169169

170170
// Pause/unpause all alerts

0 commit comments

Comments
 (0)