there is an array that displays the data by the number of elements, every time the callapi receives the type as blob, passes it through the fileReader and returns the data to render the component but the data is not displayed
export default function App() {
const arr = [
{ name: "A", id: 1 },
{ name: "B", id: 2 },
{ name: "C", id: 3 }
];
const Render = () => {
return arr.map((item) => {
const fetchAttachment = async () => {
try {
const res = await axios.get(`apiURL/${item.id}`, {
responseType: "blob",
headers: defaultHeader
});
let reader = new window.FileReader();
reader.readAsDataURL(res.data);
reader.onload = () => {
let link = reader.result;
return link;
};
} catch (error) {
console.log(error);
}
};
const linkview = fetchAttachment();
return <Item linkview={linkview} />;
});
};
return (
<div className="App">
<Render />
</div>
);
}
export function Item({ linkview }) {
return (
<div>
<p>{linkview}</p>
</div>
);
}