#SenorKarlos - expand

1 messages ยท Page 1 of 1 (latest)

bold epoch
#

Hi there!

obtuse mesa
#

Heya i was just editing as you replied LOL

bold epoch
#

What exactly are you trying to expand? Just the subscription object?

#

If so, it should be expand:[ "data.subscriptions" ]

obtuse mesa
#

I need to parse a list of customers and compare their subscription price plans to config values to assign and remove discord roles

I'm accessing the customer list object

bold epoch
#

Have you tried my suggestion above?

obtuse mesa
#

considering the customer list doesn't return a list of subscriptions... no O.o lol

I'm about to try what I reasoned with tracer code, are you sure you know what I was asking? ๐Ÿ˜‚ :p

#

(which failed ๐Ÿ˜‚ ) things need to make sense to me, I'll try it but I don't understand it

bold epoch
#

considering the customer list doesn't return a list of subscriptions... no O.o lol
If you use expand:[ "data.subscriptions" ], it does.

obtuse mesa
#

๐Ÿคฆโ€โ™‚๏ธ sorry LOL

I don't get why though, I thought you had to call the item you were looking for and it warns about 4 lvl depth, and that just expanded an object 4 layers deep from an object 'address' that doesn't 'exist' as I understand LOL

#

I think it did anyways, I'm going to put a tracer in for the actual sub data object, forgot console log doesn't form out all the trees

bold epoch
#

So did it solve your issue?

obtuse mesa
#

it's an ontime function in the main script, just ran. got an error looking for the property I would expect, but I don't seem to know much ๐Ÿ˜‚

bold epoch
#

Note that using expand:[ "data.subscriptions" ] will show thesubscriptions object only if the customer has at least one subscription. But if you are listing all customers, many probably don't have one.

obtuse mesa
#

which is fine, the parse logic later handles that

#

assuming i can get the damn property right to see if I have it ๐Ÿ˜‚ this is embarrassing ... i'm so new at all this

bold epoch
#

No worries! And can you clarify exactly which property you are looking for?

obtuse mesa
#

I was being dumb about it tbh, I was trying to log the subscriptions[0].data object up in the list function, and wasn't indexing something right in the prefixing or always indexing a test cx with no sub

I've moved it into the parse logic, which if it makes it there... I've already won I guess lol

bold epoch
#

Great!

obtuse mesa
#

well that looks like a big ol subscription object with the plan.id available ๐Ÿ˜…

i still don't quite get what's goin on with the expand thing, but it works lol. expand just looks for any property in the objects below matching that partial address?

#

I'd also then assume I should change my less used single fetch to what you just told me? ๐Ÿ˜„

        stripe_js.customers.retrieve(
          customer_id, { expand: ['customer.subscriptions.data'], },
bold epoch
#

i still don't quite get what's goin on with the expand thing,
When listing customers, by default you get data[] that contain customer objects. if you want to expand the subscription of the customer, you need to use expand:[ "data.subscriptions" ]

obtuse mesa
#

but to my poor brain just learning objects, data contains data[].customer lol

#

so calling something "that doesn't exist" at that address. If i tried to log "data.subscriptions" i'd get undefined

#

I'm just glad it works at this point tbh ๐Ÿ˜‚ something something api magic

#

now I'm trying to figure out why my code prints a verification twice, but that's not a question for here ๐Ÿ˜‚ ROFLMAO

#

thanks for the help and the patience with me, I don't express confusion well initially

#

workin on that

bold epoch
#

Happy to help ๐Ÿ™‚

obtuse mesa
#

have a great day!