-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Johann ELSASS
committed
Mar 8, 2024
1 parent
d2752ee
commit 1cac194
Showing
4 changed files
with
77 additions
and
96 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,6 @@ | ||
let texto = document.getElementById('testimonio'); | ||
import { getFirestore, collection, getDocs } from 'https://www.gstatic.com/firebasejs/10.8.1/firebase-firestore.js' | ||
|
||
// MÉTODO PARA OBTENER POSTS | ||
async function getPosts(id) { | ||
|
||
return await fetch(`https://jsonplaceholder.typicode.com/posts?userId=${id}`) | ||
.then((resp) => { | ||
return resp.json(); | ||
}) | ||
.then((post) => { | ||
for (let i = 0; i < 4; i++) { | ||
return post; | ||
} | ||
}).catch((error) => { | ||
console.log('ERROR: ', error); | ||
}); | ||
} | ||
|
||
// MÉTODO PARA OBTENER USUARIOS | ||
async function getUsers() { | ||
await fetch('https://jsonplaceholder.typicode.com/users') | ||
.then((resp) => { | ||
return resp.json(); | ||
}) | ||
.then((user) => { | ||
|
||
for (let i = 0; i < 4; i++) { | ||
const usuario = user[i]; | ||
getPosts(usuario.id).then(resp => { | ||
usuario.posts = resp; | ||
user[i] = usuario; | ||
let string = ''; | ||
|
||
if (user[i].id === 1) { | ||
string += ` | ||
<div class="carousel-item active"> | ||
<img class="d-block mx-auto" src="images/person_${i + 1}.jpg" alt=""> | ||
`; | ||
} else { | ||
string += ` | ||
<div class="carousel-item"> | ||
<img class="d-block mx-auto" src="images/person_${i + 1}.jpg" alt=""> | ||
`; | ||
} | ||
|
||
string += ` <p class="text-center sliderText">${usuario.posts[0].body}</p>`; | ||
string += `<p class="text-center"><b>${usuario.name}</b></p>`; | ||
string += `</div>`; | ||
|
||
texto.innerHTML += string; | ||
|
||
; | ||
}); | ||
} | ||
}).catch((error) => { | ||
console.log('ERROR: ', error); | ||
}); | ||
} | ||
|
||
getUsers(); | ||
export async function getQuotes() { | ||
const db = getFirestore(); | ||
return getDocs(collection(db, "quotes")); | ||
} |