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

239
Visualizações
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 à 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