Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit 21a0767

Browse files
committed
best practice with async to avoid multiple callbacks being fired
1 parent b3dd8b3 commit 21a0767

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

initializers/dataAccess.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,15 +135,15 @@ function executePreparedStatement(api, sql, parameters, connection, next, db) {
135135

136136
req({ url: javaReadBridge, method: "POST", body: body, json: true }, function(error, response, body) {
137137
if (error) {
138-
cb(error);
138+
return cb(error);
139139
}
140140

141141
if (response.statusCode != 200) {
142-
cb(JSON.stringify(body));
142+
return cb(JSON.stringify(body));
143143
}
144144

145145
api.log("Response:" + JSON.stringify(body), "debug");
146-
cb(null, body.results);
146+
return cb(null, body.results);
147147
});
148148
} else {
149149
api.log("Database connected", 'debug');

0 commit comments

Comments
 (0)