mirror of
https://github.com/karl0ss/homepage.git
synced 2025-04-29 12:03:41 +01:00
Add a little debugging to stocks endpoint
This commit is contained in:
parent
93c18a8077
commit
0c352b1843
@ -1,9 +1,14 @@
|
|||||||
import cachedFetch from "utils/proxy/cached-fetch";
|
import cachedFetch from "utils/proxy/cached-fetch";
|
||||||
import { getSettings } from "utils/config/config";
|
import { getSettings } from "utils/config/config";
|
||||||
|
import createLogger from "utils/logger";
|
||||||
|
|
||||||
|
const logger = createLogger("stocks");
|
||||||
|
|
||||||
export default async function handler(req, res) {
|
export default async function handler(req, res) {
|
||||||
const { watchlist, provider, cache } = req.query;
|
const { watchlist, provider, cache } = req.query;
|
||||||
|
|
||||||
|
logger.debug("Stocks API request: %o", { watchlist, provider, cache });
|
||||||
|
|
||||||
if (!watchlist) {
|
if (!watchlist) {
|
||||||
return res.status(400).json({ error: "Missing watchlist" });
|
return res.status(400).json({ error: "Missing watchlist" });
|
||||||
}
|
}
|
||||||
@ -56,6 +61,7 @@ export default async function handler(req, res) {
|
|||||||
// Finnhub free accounts allow up to 60 calls/minute
|
// Finnhub free accounts allow up to 60 calls/minute
|
||||||
// https://finnhub.io/pricing
|
// https://finnhub.io/pricing
|
||||||
const { c, dp } = await cachedFetch(apiUrl, cache || 1);
|
const { c, dp } = await cachedFetch(apiUrl, cache || 1);
|
||||||
|
logger.debug("Finnhub API response for %s: %o", ticker, { c, dp });
|
||||||
|
|
||||||
// API sometimes returns 200, but values returned are `null`
|
// API sometimes returns 200, but values returned are `null`
|
||||||
if (c === null || dp === null) {
|
if (c === null || dp === null) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user