diff --git a/src/lib/alarms/trade_history.ts b/src/lib/alarms/trade_history.ts index 62d0a18..d1f150b 100644 --- a/src/lib/alarms/trade_history.ts +++ b/src/lib/alarms/trade_history.ts @@ -80,7 +80,7 @@ async function getTradeHistoryFromAPI(): Promise { } const data = (await resp.json()) as TradeHistoryAPIResponse; - return data.response.trades + return (data.response?.trades || []) .filter((e) => e.status === 3) // Ensure we only count _complete_ trades (k_ETradeStatus_Complete) .filter((e) => !e.time_escrow_end || new Date(parseInt(e.time_escrow_end) * 1000).getTime() < Date.now()) .map((e) => { diff --git a/src/lib/alarms/trade_offer.ts b/src/lib/alarms/trade_offer.ts index 22539e5..5e46a0d 100644 --- a/src/lib/alarms/trade_offer.ts +++ b/src/lib/alarms/trade_offer.ts @@ -237,7 +237,7 @@ async function getSentTradeOffersFromAPI(): Promise { } const data = (await resp.json()) as TradeOffersAPIResponse; - return data.response.trade_offers_sent.map(offerStateMapper); + return (data.response?.trade_offers_sent || []).map(offerStateMapper); } async function getSentAndReceivedTradeOffersFromAPI(): Promise<{ @@ -260,8 +260,8 @@ async function getSentAndReceivedTradeOffersFromAPI(): Promise<{ const data = (await resp.json()) as TradeOffersAPIResponse; return { - received: data.response.trade_offers_received.map(offerStateMapper), - sent: data.response.trade_offers_sent.map(offerStateMapper), + received: (data.response?.trade_offers_received || []).map(offerStateMapper), + sent: (data.response?.trade_offers_sent || []).map(offerStateMapper), steam_id: access.steam_id, }; }