Shopify Product Subscription Extension

70 Views Asked by At

How to save the data from Shopify Subscription Create Extend Method?

I am not able to save the data? What server-url I need to add? Is this would be my "shopify-url" or not? What is supposed to be in "any-header-key" ?

const onPrimaryAction = useCallback(async () = { const token = await getSessionToken(); let payload = { productId: data.productId, variantId: data.variantId, }; const method = "POST"; // Send the form data to your app server to create the new plan. const response = await fetch( "server-url", { headers: { "any-header-key": token || "unknown token", }, method, body: JSON.stringify(payload), } ); if (response.ok) { done(); } else { console.log("Handle error."); } close(); }, \[getSessionToken, done, close\]); I got an error: Access to fetch at 'https://abc.myshopify.com/' from origin 'https://cdn.shopify.com' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

I am also passing shopify-url in Header like : "abc.myshopify.com". What url I neeyour textd to pass? Is that would be shopify url or the server url?

0

There are 0 best solutions below