Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!