'how to show a fetch a string using javascript and display in html

I have Uploaded a fully string data in IPFS:- the URL is:- https://bafybeih3u62l664yz4ffpgrjci6ytl64rbivsgpovv6csty3j6kbx6natm.ipfs.infura-ipfs.io/ I put this URL in browser and it perfectly showing it, is there any way, I can fetch this URL using JavaScript and show it to frontend like a image source attribute



Solution 1:[1]

You can do this

 fetch('https://bafybeih3u62l664yz4ffpgrjci6ytl64rbivsgpovv6csty3j6kbx6natm.ipfs.infura-ipfs.io/')
 .then(response => response.text())
 .then(data =>{
     document.getElementById('yourimg').src = data;
 });
   
    

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Sheikh Haziq