The back-end interface returns the picture and prints it out to be a pile of garbled codes. How to display it?

the backend interface returns the picture printed out is a pile of garbled code, how to display

GIF89a stories, / h "(OCU" Q "EO;"? "F" zvC "N" zqc "l" V+ "8"1" EO; } "tn" z "GI" ^ $"y"7 +" ^ "^" d "w] L" 7 "" Y "_ X" Fa "uaGU" P "- sharp >" aT, " "
.
/ No, no, no. {
"code": 200
}

after converting it with createObjectURL, it still cannot be displayed

clipboard.png

        const myBlob = new window.Blob([data], {type: "image/gif"})
        const qrUrl = window.URL.createObjectURL(myBlob)
        var img = document.createElement("img")
        img.src = qrUrl
        img.onload = function () {
          window.URL.revokeObjectURL(qrUrl)
        }
        const imgDiv = document.querySelector(".qr-div")
        imgDiv.appendChild(img)

according to Baidu"s method on the Internet, it is not possible to
transfer to base64
"data:image/gif;base64," + Base64.encode (res.data.toString ())

).
  1. what should the front end do when the backend should not be returned?
  2. the string of garbled codes just now should be displayed after the picture format is printed, but what is the following code: 200s, is it superfluous?

resolved:

axios responseType: "blob"
createObjectURL
```
    const qrUrl = window.URL.createObjectURL(res.data)
    var img = document.createElement("img")
    img.src = qrUrl
    img.onload = function () {
      window.URL.revokeObjectURL(qrUrl)
    }
    const imgDiv = document.querySelector(".qr-div")
    imgDiv.appendChild(img)
```

shouldn't you ask the backend directly if you return garbled codes?
Let the backend return a properly formatted data.


do you include 2000s? 200 should be a status code, remove the following json, and then transfer it. Or finally, let the backend return
{"img": data, "code": 200}

to encode the image
.
Menu