How to convert data binary into image in reactjs?

前端 未结 1 955
太阳男子
太阳男子 2021-01-24 02:49

I\'m already trying this, but it still not working for me how to convert the binary data to image in reactjs

here my code

        return axios.post(`${API_         


        
相关标签:
1条回答
  • 2021-01-24 03:20

    You can do this:

    <img src={`data:image/*;base64,${props.generated}`} alt="generated motif" />
    

    But you must ensure response from your API is something that can be decoded.

    See PHP's base64_encode() and this Stackoverflow answer.

    0 讨论(0)
提交回复
热议问题