Friday, May 17, 2024
 Popular · Latest · Hot · Upcoming
46
rated 0 times [  48] [ 2]  / answers: 1 / hits: 13604  / 7 Years ago, sat, october 7, 2017, 12:00:00

I am trying out the new Firestore by Firebase. When I run the code sample from https://firebase.google.com/docs/firestore/manage-data/add-data?authuser=0, I am getting an error.



// Add a new document with a generated id.
db.collection(cities).add({
name: Tokyo,
country: Japan
})
.then(function(docRef) {
console.log(Document written with ID: , docRef.id);
})
.catch(function(error) {
console.error(Error adding document: , error);
});



Exception caught: (FirebaseError) : Function CollectionReference.add() requires its first argument to be of type object, but it was: a custom Object object




Edit:
Sorry I didnt mention I am using GWT and JSNI, it's working fine without gwt


More From » firebase

 Answers
10

This is likely a cross-window issue: GWT code runs in an iframe; if Firebase is looking for a bare object, it likely compares the object's constructor, which won't be the expected one if the object crosses the iframe boundary.



Maybe try using a new $wnd.Object() instead of {} or new Object().


[#17640] Friday, October 6, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
morganm

Total Points: 626
Total Questions: 95
Total Answers: 95

Location: South Sudan
Member since Sun, Jul 11, 2021
3 Years ago
;