Skip to content

Commit f626845

Browse files
Fixed the observations and timeseries get function throwing an error for an undefined id
1 parent 9717834 commit f626845

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

api/endpoints/observations/model.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ module.exports = {
139139
await client.connect().catch(reject);
140140
const res = await client.query(getQuery, [id]).catch(reject);
141141
client.end();
142-
resolve(format(res.rows[0], urlResolver));
142+
resolve(res.rowCount > 0 ? format(res.rows[0], urlResolver) : undefined);
143143
});
144144
}
145145
};

api/endpoints/timeseries/model.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ module.exports = {
8686
await client.connect().catch(reject);
8787
const res = await client.query(getQuery, [id]).catch(reject);
8888
client.end();
89-
resolve(format(res.rows[0], urlResolver));
89+
resolve(res.rowCount > 0 ? format(res.rows[0], urlResolver) : undefined);
9090
});
9191
},
9292
listObservations: async function(id, start, count, urlResolver = defaultUrlResolver, options) {

0 commit comments

Comments
 (0)