mirror of
https://github.com/Floriansylvain/projet_programmation_web.git
synced 2026-08-19 11:43:16 +02:00
✨ Introduced big DB (~500 000 results) and multiple improvements
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
|
||||
function requestToApi(author) {
|
||||
fetch(`api.php?author=${author}`)
|
||||
.then(response => response.json())
|
||||
.then(data => displayResults(data))
|
||||
}
|
||||
|
||||
function displayResults(results) {
|
||||
results.forEach(function(elem) {
|
||||
|
||||
let result = document.createElement('div')
|
||||
result.classList.add('result-element')
|
||||
|
||||
let i = 0
|
||||
|
||||
elem.forEach(function(e) {
|
||||
let child = document.createElement(i === 0 ? 'h1' : 'p')
|
||||
child.innerText = e
|
||||
result.appendChild(child)
|
||||
i += 1
|
||||
})
|
||||
|
||||
document.getElementById('results').appendChild(result)
|
||||
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user