user13427179
user13427179

Reputation:

not able to display data in webpage

Hi I am new in react JS in my application my data is displayed in console but not display in webpage don't know what's going on wrong please help please help i want to display my console data in my webpage

https://ibb.co/tLG0vqg

Row.js

import React from 'react';
import Axios from './Axios';

 class Row extends React.Component {
    constructor(props){
        super(props)

        this.state = {
            movies:[]
        }
    }

    fetchData = async () => {
        const movies = await Axios.get(this.props.fetchUrl);
        this.setState(movies.data.results);
        console.log(movies);
        return movies;
    }

    componentDidMount(){
        this.fetchData();

    }

    render() {

        const {movies} = this.state

        return (
            <div className='row'>
              <h3> {this.props.title}</h3>
              <div className='row_poster'>
                  {
                      movies.map(movie =>(
                            <img src={movie.poster_path}  alt={movie.name}/>
                        ))
                  }
              </div> 
            </div>
        )
    }
}

export default Row;

Upvotes: 0

Views: 63

Answers (1)

Gucal
Gucal

Reputation: 923

Try updating the state correctly.

this.setState({movies: movies.data.results})

Upvotes: 1

Related Questions