Answer the question
In order to leave comments, you need to log in
How to send data with a file from the client (React) and receive it on nodejs?
There is a form, regular fields + file attachment
If you do this:
let data = {
name,
email,
title,
message,
file: fileInput.current.files["0"],
}
let options = {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: data,
}
fetch("http://localhost:8000/send", {
options,
}).then(...
Answer the question
In order to leave comments, you need to log in
It is very convenient through the react-hook-form the minimum number of renders, well, as mentioned above, it will be necessary to append everything through the formdata
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question