aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-09-05 12:24:59 -0700
committerAdam Soltys <[email protected]>2024-09-05 12:24:59 -0700
commit314ea1e185152b87adb614de90253db73fc9b5b2 (patch)
treeca23d2820902ded1910b0bb16ade0e01903b560d /lib
parent0bee12ea480282a500623acfa9b5f66f9ee0f00c (diff)
downloadcoinos-server-314ea1e185152b87adb614de90253db73fc9b5b2.tar.gz
coinos-server-314ea1e185152b87adb614de90253db73fc9b5b2.zip
handle empty rates
Diffstat (limited to 'lib')
-rw-r--r--lib/rates.ts3
1 files changed, 2 insertions, 1 deletions
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];