1👍
I am assuming you were getting the error when using new FormData. I don’t use view but here is an example in remix where I need to send an image and data.
export async function recommend(data, image) {
const baseUrl = process.env.BASE_URL
const query = `/api/recommendations`;
const url = baseUrl + query;
const hasImage = image._name === "" ? false : true;
const formData = new FormData();
formData.append('data', JSON.stringify(data));
if (hasImage) formData.append('files.image', image, image.name);
const response = await fetch(url, {
method: 'POST',
body: formData,
})
return response.json();
}
notice how I am appending my strapi data, I am not passing it individually like you were doing, I passing the whole object to ‘data’.
formData.append('data', JSON.stringify(data));
Hope this helps.
👤Paul
- [Vuejs]-Adding elements from html node to vuejs data
- [Vuejs]-Vuejs dynamic routes with variable parameters
Source:stackexchange.com