How to Create files in Shopify theme Without Using Asset API?

51 Views Asked by At

Currently I'm using the Asset API to Create files in the Shopify theme on app installation through the Asset API. What is the alternate way to do the same.

async function createTemplate(requestPayload, mainThemeId) {
  const url = `https://${shopifyStoreUrl}/admin/api/2022-04/themes/${mainThemeId}/assets.json`;
  console.log("Main Theme id is =========================== :", mainThemeId);
  const accessToken = shopifyAdminAPIAccessToken;

  try {
    const response = await axios.put(url, requestPayload, {
      headers: {
        'Content-Type': 'application/json',
        'X-Shopify-Access-Token': accessToken,
      },
    });
    console.log('create Tempalte Result:', response.data);
  } catch (error) {
    console.log('An error occurred at createTemplate:', error.message);
  }
}

0

There are 0 best solutions below