-
-
Save vanadium23/a0cfcc0644c9571f752b43ad6b042c02 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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