mirror of
https://github.com/Gabi-Zar/Images-Scrapper-JS.git
synced 2026-04-17 05:36:06 +02:00
Add back-end
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
const starsNumber = 1000;
|
||||
const searchInput = document.getElementById("search-input");
|
||||
const searchForm = document.getElementById("search-form");
|
||||
|
||||
let imagesUrls = [];
|
||||
|
||||
starsCanvas(starsNumber);
|
||||
searchForm.addEventListener("submit", function (event) {
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
window.addEventListener("resize", () => {
|
||||
starsCanvas(starsNumber);
|
||||
@@ -72,3 +80,17 @@ function starsCanvas(number) {
|
||||
|
||||
animate();
|
||||
}
|
||||
|
||||
async function getImagesURL(query, offset = 0, count = 100) {
|
||||
const url = `/api/getImagesURL?q=${encodeURIComponent(query)}&offset=${offset}&count=${count}`;
|
||||
const response = await fetch(url);
|
||||
const data = await response.json();
|
||||
for (const url of data) {
|
||||
imagesUrls.push(url);
|
||||
}
|
||||
console.log(imagesUrls);
|
||||
}
|
||||
|
||||
async function search() {
|
||||
await getImagesURL(searchInput.value);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user