Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Pass data from application to the front-end

Pass data from application to the front-end

Dmytro_Chr
Shopify Partner
6 0 0

Hello guys! I am developing shopify app for the first time. And unfortunately I can't find necessary information.

I created own app and I added some functionality for it. My app can store some settings to the sqlite db. Now I need to pass this data (from sqllite) to the theme. Please tell me it's possible? If yes how I can do it? Thanks.

Replies 6 (6)

HunkyBill
Shopify Partner
4853 60 568

You need to use the App Proxy for that. It allows you to add an endpoint to your App. You can securely call that endpoint using Javascript from your theme. Thus you can create any kind of App-based DSL to service your theme with your special needs. 

https://docs.shopify.com/api/reference/application-proxies

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
hieunoobpro
Shopify Partner
16 0 1

Hey, have you find the solve yet? I have problem same as you now. After i get request from frontend, i can't return response data. it's always console.log error 404. I don't know why?

 

Dmytro_Chr
Shopify Partner
6 0 0

@HunkyBill

Thank a lot for your answer. It's helped me.

But now I have another issue. I see "bad request" error with proxy request.

Details:

1 app settings

2 request on local machine

3 request from shopify (ERROR)

4 the same as shopify request on the local machine

May be you know why I get error on the 3rd point? Thanks!

Dmytro_Chr
Shopify Partner
6 0 0

UPD: I resolved this issue by adding 'thin' to gemfile

HunkyBill
Shopify Partner
4853 60 568

While thin works well, you might try Unicorn for a faster experience. I moved away from thin when I started getting a lot of hits to my services endpoints.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com

Dmytro_Chr
Shopify Partner
6 0 0

Thanks for information man

My small question) How I can pass liquid view to sidebar for example? Not to new separate page.

Now my test controller looks like this

render :layout => false, :content_type => 'application/liquid'