From 39bb937f9d7cd64e4d2d31db8ed3ab6e9b59321a Mon Sep 17 00:00:00 2001 From: Zaid Humaimidi Date: Tue, 29 Aug 2023 12:20:53 -0700 Subject: [PATCH] Fix oversight in commit 58488eb --- lib/ui/api.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ui/api.ts b/lib/ui/api.ts index bc7d8aa..1395c1b 100644 --- a/lib/ui/api.ts +++ b/lib/ui/api.ts @@ -93,8 +93,8 @@ router.get(`/devices/:id.csv`, async (ctx) => { return void (ctx.status = 403); } - const res = await db.query("devices", filter); - if (!res[0]) return void (ctx.status = 404); + const { value: device } = await db.query("devices", filter).next(); + if (!device) return void (ctx.status = 404); ctx.type = "text/csv"; ctx.attachment( @@ -108,8 +108,8 @@ router.get(`/devices/:id.csv`, async (ctx) => { "Parameter,Object,Object timestamp,Writable,Writable timestamp,Value,Value type,Value timestamp,Notification,Notification timestamp,Access list,Access list timestamp\n" ); - for (const k of Object.keys(res[0]).sort()) { - const p = res[0][k]; + for (const k of Object.keys(device).sort()) { + const p = device[k]; let value = ""; let type = ""; if (p.value) {