Skip to content

Instantly share code, notes, and snippets.

@vanadium23
Created February 11, 2023 17:32
Show Gist options
  • Save vanadium23/a0cfcc0644c9571f752b43ad6b042c02 to your computer and use it in GitHub Desktop.
Save vanadium23/a0cfcc0644c9571f752b43ad6b042c02 to your computer and use it in GitHub Desktop.
async function search_movie(search_term) {
// https://kinopoiskapiunofficial.tech/api/v2.1/films/search-by-keyword?keyword=Rashomon&page=1
const apiUrl = new URL('https://kinopoiskapiunofficial.tech/api/v2.1/films/search-by-keyword');
const params = {
page: 1,
keyword: search_term,
}
Object.keys(params).forEach(key => apiUrl.searchParams.append(key, params[key]));
const response = await fetch(apiUrl, {
headers: {
'X-API-KEY': '....'
}
});
const movie = await response.json();
return movie.films || [];
}
module.exports = search_movie;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment