diff --git a/package-lock.json b/package-lock.json index a9762c5a..0091cca1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,18 @@ { - "name": "escuelajs-reto-05", + "name": "js-challenge", "version": "1.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "escuelajs-reto-05", + "name": "js-challenge", "version": "1.0.0", - "license": "ISC", + "license": "MIT", "dependencies": { "cypress": "10.0.1" }, "devDependencies": { - "live-server": "^1.2.2" + "live-server": "1.2.2" } }, "node_modules/@colors/colors": { diff --git a/src/index.js b/src/index.js index eb2631c2..7e538b2f 100755 --- a/src/index.js +++ b/src/index.js @@ -1,14 +1,67 @@ const $app = document.getElementById('app'); const $observe = document.getElementById('observe'); const API = 'https://api.escuelajs.co/api/v1/products'; +const API_5TO10 = (init,limit) =>`https://api.escuelajs.co/api/v1/products?offset=${init}&limit=${limit}`; -const getData = api => { +console.log('test'); + +const isIntersecting = (entry) => { + return entry.isIntersecting +} +const accion = () => { + console.log('hola.'); +} +const intersectionObserver = new IntersectionObserver(entries => { + // logic... + entries + .filter(isIntersecting) + .forEach(accion) +}, { + rootMargin: '0px 0px 100% 0px' +}); +const registerItem = (item) => { + intersectionObserver.observe(item) +}; + +const getData = (api) => { + fetch(api) + .then(response => response.json()) + .then(response => { + + //console.log(response); + + let products = response; + let output = products.map(product => { + + return '