#file upload endpoint
1 messages · Page 1 of 1 (latest)
I pass the file (image) client-side as
export const postFile = async ({ url, token, file }) => {
const formData = new FormData()
formData.append('form data', file)
const res = await fetch(url, {
method: 'POST',
headers: new Headers({ token }),
credentials: 'same-origin',
body: formData
});
if (res.error) {
throw error;
}
return res.json();
};
I'm grabbing the file in my api endpoint like
const file = req.body;