0
votes

I want to access the admin/products.json and admin/metafields.json within my theme's javascript, so that I can display certain data outside of the product's page. Is it possible to do this within my theme files, or is it required that I create an external API application?

https://docs.shopify.com/api/product
https://docs.shopify.com/api/metafield

(example URL: https://apikey:password@hostname/admin/resource.json)

I have created a "Private App" API Key/Password through Shopify dashboard. How can I authenticate a GET request within a javascript file that is part of my theme, so I can create variables from the data?

What I'm actually trying to accomplish is showing data (metafields) from certain products on a related product pages. All the info I need is in these 2 JSON files

Creating and external app seems a bit overkill for obtaining data within my shop, but if this is required, how should I go about this? I'm not an expert with APIs or creating apps and I've been reading everything to find a best course of action.

Thanks!

1

1 Answers

0
votes

You don't need to make app to fetch data through API within store itself. Just do a ajax request having url "/admin/products.json" and it will return data.