Ir al contenido

new TryYourSize()

Esta página aún no está disponible en tu idioma.

Constructor@tryyoursize/node

Creates a client for one secret or restricted key. Create it once and reuse it.

constructor(apiKey: string, options: TryYourSizeOptions = {})
apiKeystringObligatorio

A secret key (sk_test_… / sk_live_…) or a restricted key (rk_…). Keep it in an environment variable.

optionsTryYourSizeOptionsOpcional= {}
Propiedades
apiVersionstring | undefinedOpcional

TYS-Version sent with every request (default: the version this SDK was built against).

maxRetriesnumber | undefinedOpcional

Retries of network errors, timeouts, 429, 5xx and 409 idempotency_key_in_use (default 2).

timeoutMsnumber | undefinedOpcional

Per-attempt timeout in ms (default 30,000).

baseUrlstring | undefinedOpcional

API origin (default https://api.tryyoursize.com).

fetchtypeof fetch | undefinedOpcional

A fetch implementation (default: the global fetch of Node 18+).

TypeError for a missing key, a publishable key, or no fetch.

import TryYourSize from "@tryyoursize/node";
const tys = new TryYourSize(process.env.TRYYOURSIZE_SECRET_KEY!, {
maxRetries: 2, // network errors, timeouts, 429, 5xx
timeoutMs: 30_000,
});

¿Te ha resultado útil esta página?