JSFiddle - React, Tailwind, and code Playground

Save stuff to customer-stuff-to-db

by Salmin Skenderovic

HTML

<script src="https://cdn.firebase.com/js/client/2.4.2/firebase.js"></script>
<button onclick="trylogin()">Login</button><br>
<button onclick="trypush()">push data</button>

JavaScript

var ref = new Firebase("https://timereporter.firebaseio.com/");

function trylogin() {
  var userObj = {email: "[email protected]", password: "hejsan"};
  ref.authWithPassword({
    "email": "[email protected]",
    "password": "nimlas"
  }, function(error, authData) {
    if (error) {
      console.log("Login Failed!", error);
    } else {
      console.log("Authenticated successfully with payload:", authData);
    }
  });
}

function trypush() {
  var user = ref.getAuth();
  console.log(user);
  if (user)
  {
    ref.child(user.uid).child("reports").push({
    mon: ["a", "b", "c"],
    tue: ["a", "b", "c"],
    wen: ["a", "b", "c"],
    thu: ["a", "b", "c"],
    fri: ["a", "b", "c"]
    });
  }
}