System Information
- Strapi Version: 3.24
- Operating System: Mac OS
- Database: mySql
- Node Version: 12
- NPM Version: latest
I currently have a product collection in Strapi called “Product”
The collection has the following fields:
Title, Description, ProductImages
I am attempting to upload to the collection and create a new entry via the api like so:
async function uploadStrapi(title, desc, imgInfo) {
const destFile = imgInfo.imgPath.replace("~", homeDirPath);
const fileContent = fs.readFileSync(destFile, { encoding: 'base64' });
// build for upload
let bodyData = new FormData();
bodyData.append('ProductImages', fileContent);
bodyData.append('Title', 'Omar');
bodyData.append('Description', 'this is a desc');
const { data } = await axios.post('http://138.68.53.157/auth/local', {
identifier: 'myemail@email.com',
password: 'Testingpass'
})
axios.post('http://138.68.53.157/products', bodyData, {
headers: {
'Authorization': `Bearer ${data.jwt}`,
},
})
.then(res => console.log(res));
}
This creates an empty entry in the collection. I get a response of 200 but nothing gets written in.
Am I missing something in the way I’m uploading this?