Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

366
Visualizações
Cannot send file from Vue.js using Axios to Express in order to send it by e-mail attached (nodemailer)

I've a front end in Vue.js and I'm using AXIOS to send data to the backend. I need to send some data and a PDF file (generated with jsPDF API). However the backend does not receive the file. What am I doing wrong? Any help would be really appreciated.

Generator.vue code

this.doc = new jsPDF({orientation: "p", unit: "pt", format: "a4"})
// ... doing staff to create the PDF file here... everything is done properly
var file = this.doc.output('url');
this.$axios.post(`/sendmail/`, 

            { "toEmail": "xxx@gmail.com",
              "bccEmail": "",
              "patientName": "Maria",
              "studyType": "Abdominal",
              "attachmentsFile": file
            })
            .then(response => {
                console.log('SUCCESS!', response.status, response.text);
          }).catch((error) => {
            if (error.response) {
              console.log('FAILED...', error);
              alert(error.response.data.items.message)
            } else {
              console.log('FAILED...', error);
              alert(error)
            }
          })// end AXIOS post   

Backend Express Code (index.js)

app.post('/sendmail', async (req, res) => {

    const {toEmail, bccEmail, studyType, patientName, attachmentsFile} = req.body;
      // >> attachmentsFile is empty!! not sure what I'm doing wrong
        
    const msg = {
        from: "xxxx@xx.com", // sender address
        to:  `${toEmail}`, // list of receivers
        bcc: `${bccEmail}`, // bcc - hiden
        subject: "subject " + `${patientName}` + " - " + `${studyType}`
        attachments: `${attachmentsFile}`, // PDF Attachment 
        html: "msg here ..."
    }
    // .... more code here working ok!
  } // end post

Any help would be really appreciated. Thanks!

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda