Skip to content

Instantly share code, notes, and snippets.

@jeffersonchaves
Last active January 15, 2025 18:23
Show Gist options
  • Save jeffersonchaves/26d1a4b4704f920ef506a85d8f6f7550 to your computer and use it in GitHub Desktop.
Save jeffersonchaves/26d1a4b4704f920ef506a85d8f6f7550 to your computer and use it in GitHub Desktop.
cineFind.js
function cineFind(movieName){
const apiUrl = `https://api.themoviedb.org/3/search/movie?api_key=2dbca7a779fef19d8dc0acc77384df5a&query=${movieName}&language=pt-BR`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
if (data.results.length > 0) {
const movie = data.results[0];
document.getElementById('results').innerHTML +=
`
<h2>${movie.title}</h2>
<p>${movie.overview}</p>
<img src="https://image.tmdb.org/t/p/w200${movie.poster_path}" alt="${movie.title}">
`;
}
})
.catch(error => {
console.error('Erro:', error);
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment