Firebase save data

nativescriptcore
firebase

#1
var Observable = require("data/observable").Observable;
var firebase = require("nativescript-plugin-firebase");


function createViewModel() {
    var viewModel = new Observable();
   

    viewModel.onTap = function() {

        var data = {
            name : "hello"
        }

        console.log(data)

        firebase.push(
          data
        ).then(
          function (result) {
            console.log("created key: " + result.key);
          }
        );

    }

    return viewModel;
}

exports.createViewModel = createViewModel;

firebase.push function is not working and im not getting any error please clarify…


#2

Please refer to the docs and pass in right parameters.


#3

when i console firebase i got below one .

and indise then function of init i put the push function and still at last line im getting
firebase.push error: Run init() first!

JS: {
JS:   "initialized": false,
JS:   "instance": null,
JS:   "firebaseRemoteConfig": null,
JS:   "authStateListeners": [],
JS:   "_receivedNotificationCallback": null,
JS:   "_dynamicLinkCallback": null,
JS:   "analytics": {},
JS:   "storage": {},
JS:   "mlkit": {
JS:     "textrecognition": {},
JS:     "barcodescanning": {
JS:       "BarcodeFormat": {
JS:         "1": "CODE_128",
JS:         "2": "CODE_39",
JS:         "4": "CODE_93",
JS:         "8": "CODABAR",
JS:         "16": "DATA_MATRIX",
JS:         "32": "EAN_13",
JS:         "64": "EAN_8",
JS:         "128": "ITF",
JS:         "256": "QR_CODE",
JS:         "512": "UPC_A",
JS:         "1024": "UPC_E",
JS:         "2048": "PDF417",
JS:         "4096": "AZTEC",
JS:         "CODE_128": 1,
JS:         "CODE_39": 2,
JS:         "CODE_93": 4,
JS:         "CODABAR": 8,
JS:         "DATA_MATRIX": 16,
JS:         "EAN_13": 32,
JS:         "EAN_8": 64,
JS:         "ITF": 128,
JS:         "QR_CODE": 256,
JS:         "UPC_A": 512,
JS:         "UPC_E": 1024,
JS:         "PDF417": 2048,
JS:         "AZTEC": 4096
JS:       }
JS:     },
JS:     "facedetection": {},
JS:     "imagelabeling": {},
JS:     "landmarkrecognition": {}
JS:   },
JS:   "f...
JS: firebase.init done_got it
JS: firebase.push error: Run init() first!