#Niklas-subscription-typescript

1 messages ยท Page 1 of 1 (latest)

tired cradle
#

Hey there ๐Ÿ‘‹ I see you referenced stripe-js, does this mean you're working on front-end coding?

civic sun
#

Mainly front-end, yes ๐Ÿ™‚ . But I poke around in the back-end for this project as well.

tired cradle
#

And which section are you working on when you hit this typescript error? Trying to confirm whether we should be looking at the stripe-js or the stripe-node library.

civic sun
#

This is an error encountered in the front-end, if that is what you mean with section.

#

In more detail, this is the object that is throwing the error:

#

And this is, part, of the response object, which contains and shows the plan-property and it's existence in the response

tired cradle
#

Taking a closer look

civic sun
#

Thanks!

tired cradle
#

And which API version are you using to retrieve the subscription object?

civic sun
#

I'm getting the same response with 2020-08-27 and 2019-03-14

tired cradle
#

Can you copy/paste that sub_1JZ... ID here?

civic sun
#

Sure!

#

"sub_1JZrtlFVJV8p5434mUrS9oLE"

tired cradle
#

Apologies for the delay, still digging.

civic sun
#

No worries, thanks for the digging and the assistance!

naive plaza
#

Hey there, taking over here

civic sun
#

Hello!

naive plaza
#

Can you explain the context for trying to use this like this via Stripe.js? This would normally be data you access via your server using the back-end stripe-node client, and return to your client app using your own data structures

civic sun
#

I've not been with this project from the start, but the general idea is that we need this data in the frontend to perform actions on it. And we want to access your data structures where we actually have typescript (we are running laravel without typing checks in the backend) to make sure we aren't trying to access properties that's been changed or deprecated.

We've recently rebuilt the frontend using typescript and that is why we are now discovering this inconsistency in the api-response vs the expected stripe-typing.

brisk crag
#

@civic sun Which type definitions are you using?

civic sun
#

Hello,

The two stripe-packages we have in the project are:
"@stripe/stripe-js": "^1.21.1"
"stripe": "^8.189.0"

From them we get the types we are using.

naive plaza
#

The stripe package is for server-side use, while Stripe.js is for client-side use. They should not be used at the time time like that.

#

If this is client-side code it should not be loading stripe

civic sun
#

We are using server-side-rendering of most components in the front-end, that's why we are importing the stripe-package as well. But thank you for the information ๐Ÿ™‚

Regardless, there is still an issue with the expected type and the actual response - is it not?

#

I have to leave work for now, but I ask you kindly to leave this thread open so that we can continue the discussion.

naive plaza
#

The types don't necessarily define all properties of the response, no. This is normal/expected.

#

expected types are fetched from "@stripe/stripe-js": "^1.21.1".