This is my App.js File Here i want to show the image from the MongoDB database.
Image from MongoDB click here to see
Image are saved as a Binary data into MongoDB
How can i Show my image in the React Page??
import React,{useState} from "react";
import "./App.css";
function App() {
const [image, setImage] = useState([]);
const btn = async() =>{
let result = await fetch("http://localhost:5000/a");
result = await result.json();
//console.log(result[0].img.data.data);
setImage(result)
}
return (
<div className="App">
<h1>Image uploading react</h1>
{
image.map((value)=>{
return(
<>
<h3>ID: {value._id}</h3>
<h3>Name: {value.name}</h3>
{/* What should I write here to show the image? */}
<img src="#" />
</>
)
})
}
<button onClick={btn}>Click Here to See the output</button>
</div>
);
}
export default App;