So, I have a Nuxt form filled with input and a file upload in it. The data structure look like this:
data() {
return {
product_name: '',
product_image: ''
}
}
In the backend, I have products table and file_uploads table. file_uploads table contain file_name and product_id (FK to products table). I have a few questions here:
- Should I append all the product data from Nuxt into a formData object in JS and the uploading file thing will be handled directly in the backend without calling separate API to upload file?
- Or should I create a new product first, return the ID of the product, and then call separate API to upload file with product_id from the return data?
Thank you in advance
Aucun commentaire:
Enregistrer un commentaire