Contentful logo

Contentful Community

How to get images

#1

I want to get all the content and print them all in the same way. I can get everything but images.

componentDidMount(){
    this.fetchPosts().then(this.setPosts);
}
fetchPosts = () => this.client.getEntries()
setPosts = response => {
    this.setState({
        posts: response.items
    })
}
render(){
    return(
            <p>{console.log(this.state)}</p>
            <Brands />
                            {
                this.state.posts.map(({fields}, i) =>
                <BoardItem key={i} {...fields} />
            )}
    )
}

}

const BoardItem = (props) => (

<div>

<img src={props.brandLogo} alt=’’/>

<p>{props.brandName}</p>

</div>

)

solved by adding this line. <img src={props.brandLogo.fields.file.url + ‘?w=200&h=200’} alt=’’/>

0 Likes

#2

Hi @alperyoruk,

Could you confirm how exactly you configured your client in this application (omitting all sensitive credentials, of course)? Also, what is the version of the SDK you’re using for this?

0 Likes