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

200
Vistas
Vue - can't show image src

I'm trying to setup a page where my vue frontend receives a qr code url from my backend. The problem is that for some reason the image is not showing. I created a simple example where request_code simulates my backend. Here is the codesandbox example.

Whenever i try to load the image in my Vue app, i get a 400 error, but if i copy the image url and open it on my browser, it will show. How can i fix this?

Code:

<template>
  <div>
    <h1>{{ qr_code }}</h1>
    <img :src="qr_code" />
  </div>
</template>

<script>
export default {
  data() {
    return {
      qr_code: "",
    };
  },
  mounted() {
    this.request_code();
  },
  methods: {
    request_code() {
      this.qr_code =
        "https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/xyTrade:root?secret=7UORYWFJCLXY4OLEWMZWQMJ2QYGK5OFI&issuer=xyTrade";
    },
  },
};
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

What i find is that you haven't applied async/await against the request_code by applying async/await it works great.

<template>
  <div>
    <h1>{{ qr_code }}</h1>
    <img :src="qr_code" />
  </div>
</template>

<script>
export default {
  name: "HelloWorld",
  data() {
    return {
      qr_code: "",
    };
  },
  async mounted() {
    await this.request_code();
  },
  methods: {
    request_code() {
      this.qr_code =
        "https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/xyTrade:root?secret=7UORYWFJCLXY4OLEWMZWQMJ2QYGK5OFI&issuer=xyTrade";
    },
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h3 {
  margin: 40px 0 0;
}
ul {
  list-style-type: none;
  padding: 0;
}
li {
  display: inline-block;
  margin: 0 10px;
}
a {
  color: #42b983;
}
</style>

about 4 years ago · Juan Pablo Isaza Denunciar
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