So my problem is quite self explanatory I'm trying to fetch data from this api https://www.hatchways.io/api/assessment/students. Now everything is working fine but I cannot figure out how to fetch the picture in this API. When I try to fetch the picture, I am getting the link as oppose to the picture itself. I think I would need to somehow use the src tag inside the loop but I'm not sure how to implement that. I will post my code below and as always I appreciate your help as I love learning more about react.
import React, {Component} from 'react';
class App extends Component{
constructor(props){
super(props);
this.state = {
items:[],
isLoaded: false
};
}
componentDidMount(){
fetch('https://www.hatchways.io/api/assessment/students')
.then(res=> res.json())
.then(({ students }) => {
this.setState({
isLoaded: true,
items: students,
})
});
}
render(){
const {isLoaded, items} = this.state;
if(!isLoaded){
return <div>loading data...</div>;
}
else{
return(
<div className="Data">
<div>
{items.map(item=>(
<p key={item.id}>
name:{item.firstName +' '+ item.lastName +' '} |
City:{item.city} |
company:{item.company} |
email:{item.email} |
id:{item.id}|
picture:{item.pic}
</p>
))};
</div>
</div>
);
}
}
}
export default App;