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

238
Vistas
Vue - get image src from API and show it

I'm trying to setup a simple page in my Nuxt project where an image url is retrieved from my backend and should be shown on the Vue frontend. The problem with my code is that the image is not shown.

Here is what i tried:

<template>
    <div>
        <img :src="qr_code" alt="" />
    </div>
</template>

<style>

</style>
<script>
import axios from 'axios'
axios.defaults.withCredentials = true;

export default {
    ssr: false,
    data(){
        return {
            qr_code: '',
        }
    },
    created(){
        this.request_code()
    },
    methods: {

        request_code(){
            return axios({
              method: 'get',
              url: 'MY-BACKEND',
              withCredentials: true,
            }).then((response) => {
                this.qr_code = response['data']['qr_code']  
            })
        }

    }
}
</script>

Here is an example of the image i'm trying to show: https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/test:test?secret=test=test

The problem with my code is that the image doesn't load at all, but i don't understand why. If i try to set qr_code: 'https://www.google.com/chart?chs=200x200&chld=M|0&cht=qr&chl=otpauth://totp/test:test?secret=test=test' it will work. What's the reason for this?

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