Am newbie in reactjs. it might be a duplicate question. Actuallly i need to show the movie name from imdb file. Am getting response from the IMDB file. But cant able to show the movie name. Please look at the below code
import React from 'react';
class App extends React.Component {
constructor() {
super();
this.state = {
items:
[
]
}
}
componentDidMount() {
this.UserList();
}
UserList() {
fetch('https://theimdbapi.org/api/find/person?name=Kamal+Haasan')
.then(items=>{
const posts = items[0].filmography(obj => obj.soundtrack);
console.log(posts)
this.setState({ posts })
}
}
render() {
return (
<div>
<div>
{this.state.items.map((dynamicComponent, i) => <Content
key = {i} componentData = {dynamicComponent}/>)}
</div>
</div>
);
}
}
class Content extends React.Component {
render() {
return (
<div>
<div>{this.props.componentData.component}</div>
<div>{this.props.componentData.id}</div>
</div>
);
}
}
export default App;
Can anone please help on this. I have to show the movie name which i need to get from the API call.
Thanks in advance
JSON.parse()UserList()as a function outside of componentDidMount when you call it only once? Why not just call the fetch function incomponentDidMount()?.then()function call.... do you close the curly brace of the arrow functionitems=>{