Last active
April 6, 2024 23:43
-
-
Save mdwitr0/9852d425597190207a0421b281de4b81 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
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