Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
React read image url from link to server path

I have an api that looks like this :

{
        "id": 9,
        "fullnames": "JOHN DOE",
        "email": "johndoe@gmail.com",
        "status": "Active",
        "directreport": null,
        "date_created": "2021-11-01T09:29:33.000+0000",
        "date_updated": "2022-03-22T12:42:50.000+0000",
        "view": true,
        "lineManager": 43,
        "accessLevel": "Level1",
        "lastLogIndate": "06-Apr-2022 13:08:06",
        "userPicture": "/var/www/html/media/strongnightstand.png",
    }

The userPicture is a a link to a directory in the server where all images are stored. I am trying to put the link as the image source but the image does not display. My build file is in /var/www/html/stratex while the images are in /var/www/html/media . My code looks like this :

const [avatar, setAvatar] = useState("");

 useEffect(() => {
    if(myuser) {
      setName(myuser.fullnames);
      setEmail(myuser.email);
      setTeamId(myuser.team);
      setId(myuser.id);
      setAvatar(myuser.userPicture);
    }
    
 }, [myuser]);

<CardAvatar profile>
    { avatar == null || avatar == undefined || avatar === '' || avatar == "null" ? ( <img src={Avatar} alt="..." /> )
    : avatar ? ( <img src={avatar} alt="..." /> )
    : (<img src={Avatar} alt="..." /> )}

</CardAvatar>

Any advice/help on what im doing wrong will be appreciated. Thanks

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!