13 lines
425 B
JavaScript
13 lines
425 B
JavaScript
|
export const getMovies = async (search) => {
|
||
|
const apiKey = '2fcb2848';
|
||
|
const url = `https://www.omdbapi.com/?apikey=${apiKey}&s=${encodeURIComponent(search)}`;
|
||
|
|
||
|
try {
|
||
|
const response = await fetch(url);
|
||
|
const data = await response.json();
|
||
|
return data.Search || [];
|
||
|
} catch (error) {
|
||
|
console.error("Erreur lors de la recherche de films:", error);
|
||
|
return [];
|
||
|
}
|
||
|
};
|