Shopify / js-buy-sdk

The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website. It is based on Shopify's API and provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.

Home Page:https://shopify.github.io/js-buy-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Converting GraphModel to POJO

fmoessle opened this issue · comments

Is there a way to convert the GraphModel from e.g. product.fetchAll() to a POJO?

I have issues with server-side rendering (nuxt), because the properties on e.g. a product are getter and not primitive values.

Hey @fmoessle I'm struggling with the same issue (nuxt), did you find a solution?

JSON.parse/JSON.stringify does the trick, but I feel bad for doing it 😅 .

I imagine you ran into this problem while using nuxt3/vue3 and tried to use the GraphModel with reactive()?

Exactly. JSON.parse/JSON.stringify is my workaround for the moment too.

This works, but it leaves me with the problem that the @types/js-buy-sdk are completely outdated.

I also realized this in a quite painful way 🙈 .