Hi, i'm trying to make a custom field cell with a dropzone that would upload a new media and add it to the item images.
I didn't find a way to combine local API and client behavior (drop) , so I'm fetching the api, not sure if that's the way.
I'm stuck at the item update trough PATCH. What would be the syntax to add a new relation to an images array field ?
const fd = new FormData();
fd.append('file', file, file.name);
fd.append('data', JSON.stringify({}));
const createRes = await fetch(`${API_ROOT}/api/media`, {
method: 'POST',
body: fd,
credentials: 'include',
});
const media = await createRes.json();
await fetch(`${API_ROOT}/api/mycoll/${rowData.id}`, {
method: 'PATCH',
headers: { 'Content-Type': 'application/json' },
credentials: 'include',
body: JSON.stringify({
images: {
relationTo: 'media',
value: media.doc
},
}),
});
{
name: 'images',
type: 'array',
label: 'Images',
fields: [
{
name: 'image',
type: 'upload',
relationTo: 'media',
label: 'Image',
required: true
}
]
}