-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- axios の設定を追加(baseURLを入れないと localhost から取得されてしまう)
- Loading branch information
1 parent
6b4496e
commit caa3bed
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { api as axios } from '../request'; | ||
import React, { useEffect, useState } from 'react'; | ||
|
||
type Props = { | ||
title: string; | ||
fetchUrl: string; | ||
isLargeRow?: boolean; | ||
}; | ||
|
||
type Movie = { | ||
id: string; | ||
name: string; | ||
title: string; | ||
original_name: string; | ||
poster_path: string; | ||
backdrop_path: string; | ||
}; | ||
|
||
export const Row = ({ title, fetchUrl }: Props) => { | ||
const [movies, setMovies] = useState<Movie[]>([]); | ||
|
||
useEffect(() => { | ||
async function fetchData() { | ||
const request:any = await axios.get(fetchUrl); | ||
setMovies(request.data.results); | ||
return request; | ||
} | ||
fetchData(); | ||
}, [fetchUrl]); | ||
|
||
console.log(movies); | ||
|
||
return( | ||
<div className="Row" /> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters