0

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);
  });
};
3

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.