Hi,
I’m on the road to building my first app. The only purpose of this app is to create a product with a custom price, based on some interactions on site, and then add that product to cart. The product is highly customizable, where differnet pieces can be added to the product, making the price dynamic. Creating a private app was the solution provided by the Shopify Front End Developers, so i’m trying that solution. I have followed the base setup of the app structure, following the Shopify tutorial on building apps with Node.js and React.
It’s fair to say im not known to working with APIs, nevertheless i’ve never worked in reacted so any help could is highly appreciated. I have worked plenty in css, html and basic javascript + great experience in jQuery, so I’ve been working with JavaScript before.
My main issue, is writing a script to create the product in the admin backend. I’m uncertain on how to trigger a POST, but i’m trying the following:
let new_product = {
product: {
title: Custom,
body_html: test,
vendor: Customcuff,
product_type: customproduct,
tags: Customproduct
}
};
fetch('/admin/api/2020-07/products.json', {
method: 'post',
body: JSON.stringify(new_product),
headers: {
'X-Shopify-Access-Token': process.env.SHOPIFY_API_SECRET_KEY,
'Accept': 'application/json'
},
})
Is this the correct way to post a new product to the backend? Or is there other, better solutions for doing it this way?
Lastly, is this a task that should be easy to go about, or is creating products that way of more advanced nature?
Hope to hear back from you soon!