Skip to content

Commit 5ebd307

Browse files
committed
fix(revenuecat): unwrap value envelope in list_offerings response
1 parent e6495c1 commit 5ebd307

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

apps/sim/tools/revenuecat/list_offerings.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,17 @@ export const revenuecatListOfferingsTool: ToolConfig<ListOfferingsParams, ListOf
5252

5353
transformResponse: async (response) => {
5454
await throwIfRevenueCatError(response)
55-
const data = await response.json()
56-
const offerings = data.offerings ?? []
57-
const currentOfferingId = data.current_offering_id ?? null
55+
const raw = await response.json()
56+
/**
57+
* RevenueCat's offerings endpoint may return the payload wrapped in `{ value: { ... } }`
58+
* or unwrapped. Normalize to a single shape.
59+
*/
60+
const data =
61+
raw && typeof raw === 'object' && 'value' in raw && raw.value && typeof raw.value === 'object'
62+
? (raw.value as Record<string, unknown>)
63+
: (raw as Record<string, unknown>)
64+
const offerings = (data.offerings as Array<Record<string, unknown>>) ?? []
65+
const currentOfferingId = (data.current_offering_id as string | null) ?? null
5866

5967
return {
6068
success: true,

0 commit comments

Comments
 (0)