Front end developer. Keen with JavaScript, HTML5, CSS3, JAMstack, React, Gatsby, GraphQL, Web Accessibility and
UX/UI Design Principles
Trained with Vets Who Code https://vetswhocode.io
Recently I had to pull order data from a Stripe account. I tried destructuring in the ways you describe but the only way I could get it working was this way
Front end developer. Keen with JavaScript, HTML5, CSS3, JAMstack, React, Gatsby, GraphQL, Web Accessibility and
UX/UI Design Principles
Trained with Vets Who Code https://vetswhocode.io
Recently I had to pull order data from a Stripe account. I tried destructuring in the ways you describe but the only way I could get it working was this way
Can you explain this? Thanks
What did you try instead? What's the type of the response? It's a great place for some typescript
I tried a bunch of different combos till I got the one I posted to work.
Your original example, the one that works, suggests that the response has a 'data' field.
For example:
Then you're destructuring that out and renaming it order
Your other examples would return undefined as there is no top-level 'order' object
Have you tried this
I'm not sure if this will work, as I'm not 100% sure of the structure of the response object.
Then data does not contain order. You need to try just storing the result json as a regular value, and console log it. To see what's in the result