Im working on a website with vue where i have to get images with axios from a server and put them as background images of divs. The case is that i have the urls but not all of them are correct. So im trying to make a function that makes an http request and returns me the url if that request is successful.
I thought of something like this:
Template:
<div class="element" :style="bgImg(url)"/>
Script:
methods: {
  bgImg(url) {
    axios.get(url)
      .then(response => {
        return `background-image: url(${response.config.url})`;
      })
      .cath(e) {
        throw new Error(e);
      }
  }
}
I was expecting to get the url returned from that function, but nothing happens.
 
     
     
     
     
    