Join the Webstudio community

Updated 2 months ago

Is there a way access data variables in the DOM?

At a glance

The community member is trying to access data from a GraphQL data source in a script, but they don't want to expose that data in the DOM. The comments suggest that they can bind the data within an HTML embed and assign it to a variable, but the community member is concerned that this would still reveal the data in the script. Eventually, the community member decides to set up a worker to handle the data access, which allows them to make requests to Shopify's GraphQL resources without exposing the data in the DOM.

I'm wanting to write a script that would access data pulled from a graphql data source in the data variable. Is there a way to access this data through the DOM?
1
J
a
j
12 comments
You can bind the data within an HTML embed and assign it to a variable
ok so there is no way to do it without revealing the variable in the script? I'm trying to build a headless Shopify store and I want to pull in the product data but I don't want to expose it to the DOM cause it will have some data I don't really want exposed
You want to access it through the dom but don't want it exposed in the dom? ๐Ÿซ 
What's the data you don't want exposed?
its all good I just setup a worker to do what I need
it would have been good to be able to make additional queries to shopify using the stored access tokens or data thats all didn't really want to expose that stuff
You can make most requests to shopify with the native graphQl resources which aren't exposed
This approach has some limits to it, there is a thread here if you search for shopify.
I hope this helps
@amozz create your own proxi api in the worker where you can do everything you need
yeah this is what I have done. Thanks for the confirmation
Add a reply
Sign up and join the conversation on Discord