Firebase prueba

In this example below you will see how to do a Firebase prueba with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by RubenMesa, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright RubenMesa ©

Technologies

  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>Firebase prueba</title>
  
  
  
  
  
</head>

<body>

  
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script src='https://www.gstatic.com/firebasejs/3.5.3/firebase.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/RubenMesa/firebase-prueba-aBbbXb */

  // Initialize Firebase
  var config = {
    apiKey: "AIzaSyCbc9lx8vYzlOTCpCTguJDCZwTs5zAcQ8Y",
    authDomain: "proyecto-foil.firebaseapp.com",
    databaseURL: "https://proyecto-foil.firebaseio.com",
    storageBucket: "proyecto-foil.appspot.com",
    messagingSenderId: "775712348708"
  };
  firebase.initializeApp(config);


var db = firebase.database();

function cargarUsuarios(){
    
    $.getJSON( "http://institutozonzamas.org/daw/profesores.php?callback=?", function( datos ){
          var elementos = {}
          
          $.each(datos,function(indice,dato){  //se genera el html para hacer un listado de enlaces  
              elementos["DNI "+ dato.id]={"Nombre":dato.nombre, "Apellidos": dato.apellidos}
              
          });

db.ref('agenda').set(elementos)
    }); 


db.ref("agenda").on('value', function(snapshot){
  console.log(snapshot.val());
});
}
//cargarUsuarios();

Comments