shopify-app-template-node
shopify-app-template-node copied to clipboard
form-data use for image upload but req.body and req.file in no data available.

Here my backend code for create product

It's unclear if this is an Express app or if it's using some other framework.
Assuming it's something like Express, unless you've used a body parser middleware, you'll likely need to call req.body.text() or req.body.json() to read in the body. It may still be in stream format.
@chiragDesaiPantherCodx @mkevinosullivan It uses Express, also the template already includes the body parser middleware for JSON. You just need to include your routes AFTER the following line in the server.js/index.js file that your server is in and you should be able to make any request that uses the .body attributes work fine after that.
// All endpoints after this point will have access to a request.body
// attribute, as a result of the express.json() middleware
app.use(express.json());
For files and uploads, you just need to add the following line:
app.use(express.urlencoded({ extended: true }))
and make sure you add your routes after that line for it to work properly.