I have a react app which integrated with FastAPI and MongoDB. In my project, there is a page to show some information as cards. These cards contain images, but those images are generated automatically in the backend folder. Each card contains the path of its own picture, but when I call this path in the component, it doesn't show the picture as illustrated in the picture 1. Note: I used React component class format to build my project!
Here is how each card is generated:
renderCard(card, index) {
return (
<Card key={index} className="box">
<Card.Img className="bodyImg" variant="top" src={card.coverPic} />
<Card.Body className="bodytext">
<Card.Title>{card.name}</Card.Title>
<Card.Text>{card.Placename}</Card.Text>
<Card.Text>{card.setting}</Card.Text>
<Link
to={{
pathname: "/CardInfo",
state: card,
}}
style={{ textDecoration: "none" }}
className="buttonStyle"
>
Show
</Link>
</Card.Body>
</Card>
);
}
Here is the information for two cards:
First card:
{
"_id": {
"$oid": "60fd0c3b3d4412b25bea49e7"
},
"name": "Test the coverPic",
"path": [
"C:/Users/Asma/Desktop/Projects/backend/app/videos/HaramCovid2.mp4"
],
"Placename": "Makkahh",
"setting": "Public Place",
"country": "Saudi Arabia",
"duration": "1",
"date": "2021-06-29",
"sendEmail": true,
"publish": true,
"outputVideoPath": "output/Test the coverPic.avi",
"contactRate": 1,
"userId": "60fbffa2e7db6bc44a842ea6",
"framesPath": "C:/Users/Asma/Desktop/Projects/backend/app/videos/output/",
"coverPic": "C:/Users/Asma/Desktop/Projects/backend/app/videos/output/Test the coverPic-30.png"
}
Second card:
{
"_id": {
"$oid": "60fc79bbac4f82a891c01ef2"
},
"name": "testing",
"path": [
"C:/Users/Asma/Desktop/Projects/backend/app/videos/HaramCovid2.mp4"
],
"Placename": "Haram",
"setting": "Mass Gathering",
"country": "Åland Islands",
"duration": "1",
"date": "2021-07-02",
"sendEmail": false,
"publish": false,
"outputVideoPath": "output/testing.avi",
"contactRate": 1,
"userId": "60fc79a0ac4f82a891c01ef1",
"framesPath": "C:/Users/Asma/Desktop/Projects/backend/app/videos/output/",
"coverPic": "output/testing-30.png"
}