A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hello,
I would like to call assets.json as described here: https://shopify.dev/api/admin-rest/2021-10/resources/asset#get-themes-theme-id-assets
However, I can only call "/products" endpoint with Axios. Maybe I missed something but I don't know what should I do because there is no whole code in the document.
Please give me an Axios asset API call example. I use React/Node.js
Thank you.
Solved! Go to the solution
This is an accepted solution.
After hard googling, I found that my app needs to make a read_themes permission request to the user.
Here is my solution. https://codesandbox.io/s/exapp-eppyvq?file=/src/index.js
I've only uploaded part of the source code for security.
After requesting /theme, you can get a list of themes, and then select a specific theme (e.g. live theme currently in service) and use it.
Shopify is very unfriendly to app developers.
This is an accepted solution.
After hard googling, I found that my app needs to make a read_themes permission request to the user.
Here is my solution. https://codesandbox.io/s/exapp-eppyvq?file=/src/index.js
I've only uploaded part of the source code for security.
After requesting /theme, you can get a list of themes, and then select a specific theme (e.g. live theme currently in service) and use it.
Shopify is very unfriendly to app developers.
Plus, you need to setup middleware server that requests to Shopify Database Server with access token.
router.get("/assets", async (ctx) => {
const session = await Shopify.Utils.loadCurrentSession(ctx.req, ctx.res);
// Create a new client for the specified shop.
const client = new Shopify.Clients.Rest(session.shop, session.accessToken);
// Use `client.get` to request the specified Shopify REST API endpoint.
const data = await client.get({
path: 'assets',
});
ctx.body = data;
ctx.status = 200;
});