Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting from Google Spreadsheet to Firebase, ERROR

I think most of my errors come from the updates of Firebase. But I'm getting there.

Still loving Firebase!

Ok, I'm trying to export a column demo Spreadsheet to Firebase (code bellow). The error seems to be related to the Firebase reference. I know how to fix it in my Firebase projects, but this is hooked into the Script editor of the spreadsheet.

ERROR: ReferenceError: "FirebaseApp" is not defined. (line 13, file "export")

function writeDataToFirebase() {
  var ss = 

SpreadsheetApp.openById("1rV2_S2q5rcakOuHs2E1iLeKR2floRIozSytAt2iRXo8");
  var sheet = ss.getSheets()[0];
  var data = sheet.getDataRange().getValues();
  var dataToImport = {};
  for(var i = 1; i < data.length; i++) {
    var year = data[i][0];
    dataToImport[year] = {
    caption:data[i][1]
  };
}

 var firebaseUrl = "https://test-db-9833d.firebaseio.com/";

 // ERROR HERE ********************************************

 var base = FirebaseApp.getDatabaseByUrl(firebaseUrl);
 base.setData("", dataToImport);

}
like image 744
Edward Potter Avatar asked May 28 '17 18:05

Edward Potter


1 Answers

Following is the right answer: In the script there is a resources tab to add a library: Search: MYeP8ZEEt1ylVDxS7uyg9plDOcoke7-2l and choose 11-static then rerun your script

documentation: https://sites.google.com/site/scriptsexamples/new-connectors-to-google-services/firebase

like image 122
Mark Moo Avatar answered Nov 20 '22 12:11

Mark Moo