Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions api/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const BASE_URL = 'http://www.omdbapi.com/?apikey=287c70f0&t=';

async function request(url) {
const response = await fetch(`${BASE_URL}['${url}']`);

if (!response.ok) {
throw new Error(`${response.status}`);
}

return response.json();
}

export function getMovies(title) {
return request(title);
}
54 changes: 48 additions & 6 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,50 @@
import React from 'react';
import React, { useState } from 'react';
import './App.scss';

export const App = () => (
<div>
React starter pack
</div>
);
import {getMovies} from '../api/api';


export const App = () => {
const [title, setTitle] = useState('');
const [movies, setMovies] = useState([]);
const [error, setError] = useState('');

const callback = (event) => {
setTitle(event.target.value);
}

const findMovie = async() => {
try {
const movies = await getMovies(title);
}
catch {
}
}

return(
<>
<input
type='text'
placeholder='Enter title'
value={value}
onChange={callback}
/>

<button
name='find'
type='submit'
//onClick={}
>
Find movie
</button>

<button
name='add'
type='submit'
//onClick={}
>
Add movie
</button>
</>
)
};