From 2fba5da769afdebae3b58e5a20cf3e32d0bb48b4 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:12:41 -0700 Subject: [PATCH] dont even check if theres no ticker --- src/pages/api/widgets/stocks.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/api/widgets/stocks.js b/src/pages/api/widgets/stocks.js index 12cfe2513..d80842e1b 100644 --- a/src/pages/api/widgets/stocks.js +++ b/src/pages/api/widgets/stocks.js @@ -48,6 +48,9 @@ export default async function handler(req, res) { // https://finnhub.io/docs/api/rate-limit const results = await Promise.all( watchlistArr.map(async (ticker) => { + if (!ticker) { + return { ticker: null, currentPrice: null, percentChange: null }; + } // https://finnhub.io/docs/api/quote const apiUrl = `https://finnhub.io/api/v1/quote?symbol=${ticker}&token=${apiKey}`; // Finnhub free accounts allow up to 60 calls/minute @@ -56,7 +59,7 @@ export default async function handler(req, res) { // API sometimes returns 200, but values returned are `null` if (c === null || dp === null) { - return { ticker: ticker, currentPrice: null, percentChange: null }; + return { ticker, currentPrice: null, percentChange: null }; } // Rounding percentage, but we want it back to a number for comparison