How does axios request a picture from a picture server and display it on img?

1. Front-end vue+webpackage+axios, back-end springboot
2. Zuul is used as the gateway and routing is configured. Authentication is carried out at the gateway entrance by writing token, in header
2. Use fastDFS as a file server and configure nginx for online preview
the online preview address of 3.fastDFS is not open to the public and is routed through zuul. This requires a token, so writing the image address directly to the src attribute of img is not feasible.

related codes

    getimg(){
      axios.get(process.env.BASE_API+"preview/group0/M00/00/00/rBQAHVtkLACAR2y9AAgEf2GW0sY139.png", {
        responseType: "arraybuffer",
        headers:{"validtoken":this.$store.getters.token}
      }).then(response => {
        return "data:image/png;base64," +btoa(new Uint8Array(response.data).reduce((data, byte) => data + String.fromCharCode(byte), ""));
      }).then(data=>{
        that.$refs.img.src=data;
      });

you can see that the picture is requested, but how to display it on img? The above code is written with reference to the answer above https://codeshelper.com/q/10., but it is not shown. The last data of the console.log output is only the previous short paragraph" data:image/png;base64, "

.

clipboard.png

clipboard.png

Apr.05,2021

https://www.opinionatedgeek.c.
is here to verify whether the base64 is valid


the front and rear ends are separated, and then


 getimg(){
      axios.get(process.env.BASE_API+"preview/group0/M00/00/00/rBQAHVtkLACAR2y9AAgEf2GW0sY139.png", {
        responseType: 'arraybuffer',
        headers:{"validtoken":this.$store.getters.token}
      }).then(response => {
        return  window.URL.createObjectURL(new Blob(response));
      }).then(data=>{
        that.$refs.img.src=data;
      });

how is the problem solved?


axios.get(' URL', { responseType: 'blob', })
console.log(URL.createObjectURL(res.data))

this.$http.get('get_img_url',{ responseType: 'blob'}).then((res)=>{
    let reader = new FileReader()
    reader.onload = (e) => {
        this.imgSrc = e.target.result;
    }
    reader.readAsDataURL(res.data)
}).catch((err)=>{

});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b4295c-2c61f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b4295c-2c61f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?