How do I send an image to my node js server with axios in react without a form? I'm using nodemailer on server side to send an email with text and an image attachment. The code below is what I have and it does not work as I'm not actually sending the file itself. The code works fine for sending text.
import img from "./image.jpg";
const handleRequest = async () => {
const body = {
img,
};
await axios
.post("http://localhost:3030/mail", body)
.then((res) => {
console.log("Email Sent Successfully");
})
.catch((err) => {
console.log(err);
});
};