Products is not publicly visible when called by API

Anonymous
Not applicable
1948 0 0

i have a piece of code that gets the products that i want to display as desired . The problem is that it only shows up when i am logged in .

 

      jQuery.getJSON( "https://wilde-iris.myshopify.com/admin/api/2020-07/products.json?ids=7012259332247,7012276338839,7012278927511,7012263526551,7012268900503", function(data) {
          jQuery.each(data.products, function() {
              console.log("wilde iris");
              jQuery('.content-yml').append('<a href="'+ location.origin +'/products/'+ this.handle  +'"><div class="item-product-yml">'+
                  '<img src="'+ this.image.src +'" />' +
                  '<h2>'+ this.title +'</h2>' + 
                  '<div class="price-yml">£'+this.variants[0].price+'</div>'+
                  '</div></a>');
          });
      }).done(function() {
      })
      .fail(function() {
          jQuery('.content-yml').append('<div>An error has occurred. Sorry for the inconvenience</div>');
      });

 

I tried accessing the URL in get json when not logged in and it gives me an error 

 

{"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}

 

If there is any way please let me know. Thanks for the help !!!

0 Likes