Feeds:
Posts
Comments

Posts Tagged ‘axios’

here is a simple code to load an image coming from a web service as byte array

In the html Add this snippet

   <a v-on:click="getQR">Get QR</a>

   <img id="qr" :src="qrImg" />

And add this snippet to the methods section in vuejs

getQR() {
      var base = this;
      axios
        .get(your api url + "/QRCode", { responseType: "arraybuffer" })
        .then(function (response) {

          let base64String = btoa(
            String.fromCharCode.apply(null, new Uint8Array(response.data))
          );
          base.qrImg = "data:image/jpg;base64," + base64String;
        });
    },

Read Full Post »