From 314ea1e185152b87adb614de90253db73fc9b5b2 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 5 Sep 2024 12:24:59 -0700 Subject: handle empty rates --- lib/rates.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/rates.ts b/lib/rates.ts index f840592e..6172f5eb 100644 --- a/lib/rates.ts +++ b/lib/rates.ts @@ -16,9 +16,10 @@ let connect = async () => { ws.onmessage = async function (event) { try { let msg = JSON.parse(event.data); - let rates = await g("rates"); + let rates = await g("rates") || {}; let fx = await g("fx"); if (fx) ({ fx } = fx); + if (!fx) return; Object.keys(fx).map((symbol) => { rates[symbol] = msg.c * fx[symbol]; -- cgit v1.2.3