Advertisement
Guest User

Untitled

a guest
Mar 21st, 2018
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import React, { Component } from 'react'
  2. import axios from 'axios';
  3.  
  4. class Ghibli extends Component {
  5.   state = {
  6.     title: [],
  7.     description: []
  8.   }
  9.   componentDidMount() {
  10.     axios.get(`https://ghibliapi.herokuapp.com/films`)
  11.       .then(response => {
  12.         console.log(response.data[0].title);
  13.         console.log(response.data[0].description);
  14.         const title = response.data[0].title.map((object) => object.data);
  15.       })
  16.   }
  17.   render() {
  18.     return (
  19.       <div>
  20.         <h1>Api call to Studio Ghibli</h1>
  21.           {this.state.title.map(titles =>
  22.             <li key={titles.title}>
  23.               {titles.title}
  24.             </li>
  25.           )}
  26.       </div>
  27.     );
  28.   }
  29. }
  30.  
  31. export default Ghibli;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement