Compruebe el acceso a la colección de datos mediante el patrón de URL:
https://<nombre-del-proyecto>.firebaseio.com/<nombre-de-la-coleccion>.json
Identifique la sección del documento HTML donde agregará el contenido dinámicamente, p.e.:
<div id="resultados" class="blog-section">
<div class="container">
...
<div class="row">
<div class="p-3 p-lg-5 border bg-white">
<table class="table site-block-order-table mb-5">
<thead>
<th>Categoría</th>
<th>Conteo</th>
</thead>
<tbody id="tablebody">
<!-- Filas dinámicas -->
</tbody>
</table>
</div>
</div>
...
</div>
</div>
Identifique el o los eventos en los que realizará la petición asíncrona de datos, p.e.:
Utilice las instrucciones de Gemini para realizar un requerimiento asíncrono HTTP - GET
, de la colección de datos en firebase
, mediante fetch.
let template = `
<tr>
<td>${categoria}</td>
<td>${conteo}</td>
</tr>
`
For comparison here is how synchronous data fetching would work. pic.twitter.com/GTjqmpnz3K
— Yash (@yashguptaz) March 8, 2020
Asynchronous JavaScript Promises Visualized.
— Yash (@yashguptaz) March 8, 2020
Notice how Web APIs are given the task of processing the request and the output is received back by the main thread.
This shows how single-threaded JavaScript can do async operations.
Animation made by me. pic.twitter.com/p5vprPyxzn
fetch, sincronía, asíncrona, firebase, json, xml, HTTP - POST