Can someone help me figure out how to solve this issue? I have an API that returns a base64 image, and I want to load this image on my site. Any suggestions on where or how I should implement my function?
This is the API call located in the methods:
methods:{
async getGraph(){
const body = new FormData();
body.append('hostname','hostname');
axios({
method:'post',
url:'http://127.0.0.1:8000/api/graph',
data: body,
headers:{"Content-Type":'multipart/form-data'}
}).then(response=>{
var graphBase64 = Object.values(response.data)[0]
console.log(graphBase64)
return graphBase64
}).catch(function(response){
console.log(response)
})
}
}
And I would like to use it in this way:
<img v-bind:src="getGraph()">
I was considering placing my API call in beforeMounted
, but then the site won't load properly.
Thank you in advance for any advice, articles, or ideas!