Shopify - 在 Liquid 模板中从外部 REST API 加载数据

Shopify - Loading data from an External REST API in a Liquid template

我需要从外部 REST API 将一些数据(WordPress 菜单)加载到我的 Shopify 模板中。我假设我需要使用 App 代理来执行此操作。我已经查看了文档,但对于如何处理这个问题我有点困惑。

谁能指出我正确的方向?

我经常将 jquery 与对 api 端点的 ajax 调用一起使用

  1. 发回格式化 html
  2. 将我通过 javascript 解析并形成 html 的 json 数据发回。

    
        jQuery(window).load(function(){
            data = {};
                jQuery.ajax({
                    type: 'GET',
                    url: 'https://yourapp.herokuapp.com/yourendpoint.json',
                    data: data,
                    dataType: 'json',
                    success: function(data) { 
                        console.log(data);
                        $.each( data, function(i, item) {
                             console.log(item);
                            // do something with your data here
                        });
                    }
                });
        });