Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get img from API (React/TypeScript)?

Problem is that i see only icon while file doesn’t upload.
Thanks in advance for your help.

       import React, { FC } from "react";
       import { IUser } from "../types/Types";
       import App from "../App";
       interface UserItemProps {
        user: IUser;
       }
      const UserItem: FC<UserItemProps> = ({ user }) => {
       return (
        <body>
         <article className="UserPage">
           <h2 className="Title_options ">
           {user.title} <h6 className="Name">{user.name}</h6>
           <h6>{user.address}</h6>
           </h2>
           <img src={user.pictures} />
          </article>
         </body>
        );
       };

       export default UserItem;

Types

   export interface IUser {
        name: string;
        title: string;
        headers: string;
        id: number;
        email: string;
        address: string | number;
        pictures: string;
     }

[API][1]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

   [1]: https://i.stack.imgur.com/9uISi.png

[How it looks in Chrome][2]

   [2]: https://i.stack.imgur.com/wBaZ8.png

>Solution :

Replace this:

<img src={user.pictures} />

with this:

{user.pictures && user.pictures.map(picture => (<img src={picture} />)}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading