'Resend file from request

I have an app on React. There is a form and it sends only texts fields to node js server. Server resend info from request body to email using nodemailer.

Now I want to attach a file. And file should resend to email too. How can I do it? How can I read a formData on server?

frontend:

if (file) {
  const formData = new FormData();
  formData.append('file', file[0]);

  const req_config = {
    headers: {
      'content-type': 'multipart/form-data',
    },
  };
  axios.post(`${config.apiUrl}/forms/calc`, formData, req_config)
}

Backend:

transporter.sendMail({
    from: '...',
    to: '...',
    subject: '...',
    html: `.....`,
    attachments: [
       // what's here???
     ]
  });


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source