tys.recommendationHandle()
Esta página aún no está disponible en tu idioma.
A sealed handle for your server’s POST /v1/recommendations (headless or server-rendered pages). Send handle to your server; it gets sizes only. Null when the shopper is not signed in to TryYourSize on your site, has no body yet, or is in the A/B holdout. Expires after an hour.
recommendationHandle(): Promise<RecommendationHandle | null>;Returns
Section titled “Returns”Promise<RecommendationHandle | null>: { handle, expiresAt }, or null.
handlestringObligatorioOpaque, starts with tys_rh_; send it to your server as is.
expiresAtstringObligatorioISO date-time; ask for a new one after it (an hour).
Examples
Section titled “Examples”Browser: get a handle, send it to your server
Section titled “Browser: get a handle, send it to your server”const h = await tys.recommendationHandle();const res = await fetch("/api/sizes", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ handle: h?.handle, products: ["SKU-123", "SKU-456"] }),});Server: exchange it for sizes
Section titled “Server: exchange it for sizes”const { data } = await tys.recommendations.create({ handle, products: ["SKU-123", "SKU-456"] });answer = tys.recommendations.create(handle=handle, products=["SKU-123", "SKU-456"])See also
Section titled “See also”¿Te ha resultado útil esta página?
Gracias. Leemos todas las respuestas.