Skip to content

Instantly share code, notes, and snippets.

@mdwitr0
Last active April 6, 2024 23:43
Show Gist options
  • Save mdwitr0/9852d425597190207a0421b281de4b81 to your computer and use it in GitHub Desktop.
Save mdwitr0/9852d425597190207a0421b281de4b81 to your computer and use it in GitHub Desktop.
const headers = {
"X-API-KEY": "Your token ..."
};
async function getMoviesByName(name, page = 1, limit = 1) {
try {
const response = await fetch('https://api.kinopoisk.dev/v1.4/movie/search?' + new URLSearchParams({
"query": name,
"limit": limit,
"page": page,
}), {
headers: headers
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const movies = await response.json();
return movies.docs;
} catch (error) {
console.error(error);
}
}
getMoviesByName("аватар путь воды").then(movies => {
console.log(movies);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment