-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathMovieResult.js
More file actions
54 lines (45 loc) · 1.18 KB
/
MovieResult.js
File metadata and controls
54 lines (45 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import React from "react";
// let imdb = "https://www.imdb.com/title/";
const omd = {
apiKey: "2c6457b6&",
firstSearch: "red",
url: "http://www.omdbapi.com/"
};
class MovieResult extends React.Component {
constructor(props) {
super(props);
this.handleClick = this.handleClick.bind(this);
}
fetchMoreInfo() {
fetch(`${omd.url}?i=${this.props.movie.imdbID}&apikey=${omd.apiKey}`)
.then(response => response.json())
.then(result => {
this.props.getMoreInfo(result);
})
.catch(error => console.log(error));
}
handleClick(event) {
event.preventDefault();
this.fetchMoreInfo();
}
render() {
return (
<div className="moviecard">
<div className="cardtext">
<a onClick={this.handleClick} href={this.props.movie.Poster}>
<h2 className="movieheading">{this.props.movie.Title}</h2>
</a>
<h3>{this.props.movie.Year}</h3>
</div>
<a href={this.props.movie.imdbID}>
<img
className="poster"
src={this.props.movie.Poster}
alt="Movie Poster"
/>
</a>
</div>
);
}
}
export default MovieResult;