Skip to content

Commit

Permalink
✨ Row コンポーネントを作成
Browse files Browse the repository at this point in the history
- axios の設定を追加(baseURLを入れないと localhost から取得されてしまう)
  • Loading branch information
dodonki1223 committed Oct 19, 2021
1 parent 6b4496e commit caa3bed
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/components/Row.tsx
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" />
);
};
6 changes: 6 additions & 0 deletions src/request.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import axios from 'axios';

export const api = axios.create({
baseURL: `https://api.themoviedb.org/3/`
});

const API_KEY = "";

export const requests ={
Expand Down

0 comments on commit caa3bed

Please sign in to comment.