Shopify app with proxy extension POST requests not working

时光怂恿深爱的人放手 提交于 2020-04-18 05:36:05

问题


Following the guide here: https://shopify.dev/tutorials/display-data-on-an-online-store-with-an-application-proxy-app-extension

GET requests are working fine for me.

But when I try to do a POST request, my parameters are not coming through.

I'm building a simple wishlist app, where a user can click on a heart on a product and it adds it to a database.

So my code, when they click the heart, looks something like this:

    $.ajax({
        url: '/apps/wishlist/save',
        type: 'POST',
        data: {
            shop: shop,
            customerId: customerId,
            productId: productId
        },
        dataType: 'json',
        success: function (data) {
          console.info(data);
        }
    });

When I inspect this post in Network tab in Chrome Dev Tools, the original POST is hitting a 301, then Shopify is creating a GET request to the original URL with different/missing parameters that look like this:

shop: example.myshopify.com
path_prefix: /apps/wishlist
timestamp: 1585769299
signature: examplesignature

If I change my original AJAX request to a GET, then my original parameters are passed as expected.

Are POST requests not allowed here?


回答1:


Try to add / to the end of your url i.e. change it to /apps/wishlist/save/.



来源:https://stackoverflow.com/questions/60978973/shopify-app-with-proxy-extension-post-requests-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!