Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

191
Vistas
Vue dispaly audio file fetched from Express backend: audio/mp3

express endpoint:

app.get('/test', (request, response) =>  {
    response.sendFile("/absolute/path/to/file/myfile.mp3");
});

Test.vue:

<template>
  <div>
    <p>test {{text}}</p>
    <audio controls="controls" src="./myfile.mp3">

    </audio>
  </div>

</template>

<script>

import axios from "axios";

export default {
  name: 'Test',

  data: function ()  {
    return  {
      text: 'hello',
      audio: ""
    }
  },

  created() {
    this.$watch(
        () => this.$route.params,
        () => {
          alert("fetching")
          this.fetchData()
        },
        
        { immediate: true }
    )
  },

  methods:  {
    fetchData()  {
      axios.get('http://localhost:3000/test',
          {
            params: {

            }
          })
          .then((response) => {
             alert("done")
             alert(JSON.stringify(response));

             const url = URL.createObjectURL(response);


             alert(url);
          });
    }
  }
}
</script>

When I load the Test.vue I get:

first alert:

enter image description here

second alert:

enter image description here

third alert:

enter image description here

and then the page appears:

enter image description here

I know I need to connect the received response from express to the <audio> element, but I'm not sure how. And I noticed that alert(url) is never displayed (no alert window appears).

Express is at localhost:3000 and Vue is at localhost:8080. When I go to http://localhost:3000/test, I get the page with the playable audio file, so express backend does its job:

enter image description here

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda