gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-05 04:12:55 27 4
gpt4 key购买 nike

我需要从外部 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                        });                    }                });        });    

关于json - Shopify - 从 Liquid 模板中的外部 REST API 加载数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39211349/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com