-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathApp.tsx
32 lines (27 loc) · 901 Bytes
/
App.tsx
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
import { useCallback, useState } from "react";
import "./App.css";
import { ImdbApi, ImdbApiClient } from "./api";
import { Movie } from "./api/generated/serialization";
const BACKEND_CLIENT = new ImdbApiClient({
environment: "http://localhost:8080",
});
function App() {
const [movie, setMovie] = useState<ImdbApi.Movie>();
const onClick = useCallback(async () => {
try {
const movie = await BACKEND_CLIENT.imdb.getMovie("goodwill-hunting");
setMovie(movie);
} catch (e) {
console.error("Failed to get movie", e);
}
}, []);
return (
<div className="App">
<div className="button-container">
<button onClick={onClick}>Load movie</button>
</div>
{movie != null && <pre>{JSON.stringify(movie, undefined, 4)}</pre>}
</div>
);
}
export default App;