Reputation: 99
I'm not sure what I'm doing wrong. When I run the API calls directly from the front-end, everything works great however it exposes the API KEY, so I'm moving all functions on firebase cloud functions and for some reason the formData return empty when posting.
Front-End
let formData = new FormData();
formData.append("file", e.target.files[0], name);
formData.append("deal_id", deal.id);
console.log(formData.get("file"));
(async () => {
console.log("call");
const response = await props.putFiles({ formData });
document.querySelector(`#Y${name}`).classList.add("uploaded");
uploadedComplete(name);
setUploading({
...uploading,
[name]: false,
});
console.log(response);
})();
Cloud Function
exports.putFiles = functions.https.onCall(async (data, context) => {
return data.formData;
});
Upvotes: 1
Views: 60