You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
57 lines
1.1 KiB
57 lines
1.1 KiB
5 years ago
|
import React, { useState, useEffect } from "react";
|
||
|
import { Link } from "@reach/router";
|
||
|
import styled from "styled-components";
|
||
|
|
||
|
function Movie(props) {
|
||
|
const [movie, setMovie] = useState({});
|
||
|
const [error, setError] = useState("");
|
||
|
|
||
|
const movieId = props.movieId;
|
||
|
|
||
|
useEffect(() => {
|
||
|
const main = async () => {
|
||
|
try {
|
||
|
const Token = window.localStorage.getItem("Token");
|
||
|
const response = await fetch(
|
||
|
"https://mkr.thefeathers.in/movie/" + movieId,
|
||
|
{
|
||
|
method: "GET",
|
||
|
headers: new Headers({ Authentication: Token }),
|
||
|
},
|
||
|
);
|
||
|
const data = await response.json();
|
||
|
|
||
|
if (data.success) {
|
||
|
setError("");
|
||
|
setMovie(data.data);
|
||
|
} else {
|
||
|
setError("Error occured. " + data.msg || "");
|
||
|
}
|
||
|
} catch (e) {
|
||
|
setError("Error occured. " + e.message || "");
|
||
|
}
|
||
|
};
|
||
|
|
||
|
main();
|
||
|
}, [movieId]);
|
||
|
|
||
|
return (
|
||
|
<div>
|
||
|
{error ? <p>{error}</p> : ""}
|
||
|
<img src={movie.poster}></img>
|
||
|
{[
|
||
|
movie.movieId,
|
||
|
movie.title,
|
||
|
movie.overview,
|
||
|
movie.release,
|
||
|
movie.watchStatus,
|
||
|
movie.rating,
|
||
|
].map(value => {
|
||
|
return <div key={value}>{value}</div>;
|
||
|
})}
|
||
|
</div>
|
||
|
);
|
||
|
}
|
||
|
|
||
|
export default Movie;
|