diff --git a/src/main.ts b/src/main.ts index d81d5b0..8b8a3cf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -105,9 +105,8 @@ server.register(FastifyProxy, { return; } - // eslint-disable-next-line prefer-destructuring - const cost = data.usage.cost; - if (!cost) { + const cost = data?.usage?.cost; + if (!cost || typeof cost !== 'number') { request.log.error({ data }, 'Cannot read cost from response'); return; }