App reviews, troubleshooting, and recommendations
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hello
I just created a page using the app proxy and is there a way to deliver data to that page?
Like the code above, we are loading the liquid file using express.
And I want to hand over the data to the liquid file.
For example, when accessing the /front/view/:id path, you want to pass the ":id" value to the "view.liquid" file.
If there is no way to transfer data to liquid files, How can I write a value like ":id" in a liquid file?
Solved! Go to the solution
This is an accepted solution.
Hi @help_me,
So you've created an app proxy URL and you're now serving up a liquid file. Great! Now you want to pass data server side to that file...
First set the header content-type to "application/liquid"
res.set({
"content-type": "application/liquid"
});
Next, serve the file along with data:
const {id} = req.params;
res.render('client', {
id: id
});
You'll also want to save view.liquid as view.ejs
Finally in your view.ejs, display that data or use in a script:
<script>
var id = {{ id }};
</script>
<h1>Your ID: {{ id }}</h1>
Best,
Sam - Owner/Lead Developer
Achieve Applabs
This is an accepted solution.
Hi @help_me,
So you've created an app proxy URL and you're now serving up a liquid file. Great! Now you want to pass data server side to that file...
First set the header content-type to "application/liquid"
res.set({
"content-type": "application/liquid"
});
Next, serve the file along with data:
const {id} = req.params;
res.render('client', {
id: id
});
You'll also want to save view.liquid as view.ejs
Finally in your view.ejs, display that data or use in a script:
<script>
var id = {{ id }};
</script>
<h1>Your ID: {{ id }}</h1>
Best,
Sam - Owner/Lead Developer
Achieve Applabs
Thank you!
But there's one problem.
<h1>Your ID: {{ id }}</h1> The id value does not come out with this code, but the id value is exposed only if you write it like this <%= id %>.
{{ id }} Is there any way to do it this way?
Hi @help_me,
Right, the default template engine on Node is EJS.
Change your templating engine to Liquid on your express server. Here's a good tutorial: https://liquidjs.com/tutorials/use-in-expressjs.html
Best,
Sam
hi @Anonymous
Thank you for telling me a good way.
However, if you change the engine to liquid as you told me, the style or metafields are not working.
Is there any way to use liquid grammar well while handing over data from express?