Get custom data from app

Solved

Get custom data from app

Touchofthemind
Shopify Partner
3 1 0

I am beginner in shopify app development.

I created an app by this guide (nodejs)

I added my custom script by this scripttag api 

My app has some settings for my script which can be changed by the merchant. These settings are saved in db.

When my script loads i want to get these settings.

For example:

// server side
app.post('/settings', (req, res) => {
    res.json({});
});
// storefront script
fetch('https://xxx.eu.ngrok.io/settings', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    body: JSON.stringify({ shop: window.Shopify.shop })
}).then(() => {});

 

How can I get these setting from my app db in storefront?

 

Accepted Solution (1)

Touchofthemind
Shopify Partner
3 1 0

This is an accepted solution.

I found the answer
It is proxy

I moved to theme-app-extension 

This page helped me

How to connect proxy 

Example with proxy 

But the proxy did not work the first time. I was getting a 404 error

I hit the wall for a long time

The answer is shopify sometimes does not update proxy. I do not understand why. So i did this a few times without code change and it was my award.

 

I hope this information helps someone

View solution in original post

Reply 1 (1)

Touchofthemind
Shopify Partner
3 1 0

This is an accepted solution.

I found the answer
It is proxy

I moved to theme-app-extension 

This page helped me

How to connect proxy 

Example with proxy 

But the proxy did not work the first time. I was getting a 404 error

I hit the wall for a long time

The answer is shopify sometimes does not update proxy. I do not understand why. So i did this a few times without code change and it was my award.

 

I hope this information helps someone