Logger
Types used by the TMDB client logging feature
TMDBLoggerFn
A callback function that receives a TMDBLoggerEntry for every request,
response, and network error fired by the TMDB client.
type TMDBLoggerFn = (entry: TMDBLoggerEntry) => void;Pass it to the logger option when creating a TMDB instance:
import { TMDB, TMDBLoggerFn } from "@lorenzopant/tmdb";
const myLogger: TMDBLoggerFn = (entry) => {
console.log(entry.type, entry.endpoint);
};
const tmdb = new TMDB("your-api-key", { logger: myLogger });TMDBLoggerEntry
The object passed to your TMDBLoggerFn on every log event.
type TMDBLoggerEntry = {
type: "request" | "response" | "error";
method: "GET";
endpoint: string;
status?: number;
statusText?: string;
durationMs?: number;
tmdbStatusCode?: number;
errorMessage?: string;
};Fields
Prop
Type