Currently, I am getting products if logged in to my Shopify store in the separate tab. But if logged out from the store then getting the authentication(Shopify API Authentication) error. I have product id only to fetch product JSON (I don’t have product handle which is available globally to fetch product JSON). I want to fetch product using jQuery AJAX call. See the working snippet below:
var productId = "000000000";
jQuery.ajax({
type: 'GET',
url: '/admin/products/' + productId + '.json',
success: function(response) {
console.log("Product Object: ", response);
},
error: function(error) {
console.log("Error: "+ error);
}
});
How can I get product JSON in javascript using jQuery without admin logging in?
Thanks in Advance!
2
Answers
If you must do this from jQuery, you may be able to use the Storefront API, which is lightly authenticated. But you can’t use the Admin API in jQuery – it requires a API Key and Password, which would then be visible to anyone viewing your script. If you must use the Admin API, you will have to use an application proxy.