This repository has been archived on 2023-03-02. You can view files and clone it, but cannot push or open issues or pull requests.
react-rest-request/examples/movies/src/app.tsx

18 lines
486 B
TypeScript
Raw Normal View History

2020-11-04 14:39:57 +03:00
import React from 'react';
import { useRequest } from 'react-rest-request';
import { MoviesEndpoint, MoviesResponse } from './endpoint';
export default function App() {
const { data, loading } = useRequest<MoviesResponse>(MoviesEndpoint);
2020-11-04 14:39:57 +03:00
return !data ? (
<div>{ loading ? 'Loading...' : 'Something went wrong' }</div>
) : (
<ul>
{data.map(movie => (
<li key={movie.id}>{movie.title}</li>
))}
</ul>
);
}