Patrick Obafemi
Patrick Obafemi

Reputation: 1066

Typescript error, unexpected ',' when fetching Geopoint

I get a "Typescript error, unexpected ','" when i try to update location collection of a user field.

this is my code

import * as firebase from 'firebase';



 updateDriverLocation(latitude, longitude, id:string)
 {
    return this.DriverCollection.doc(id).update({
          location: new firebase.firestore.GeoPoint(latitude, longitude); //this is where the error points at
        });
}

Please what am i doing wrong?

EDIT: My issue with firebase not defined was i was importing it wrongly. Corrected it.

Upvotes: 0

Views: 488

Answers (2)

Gabitu
Gabitu

Reputation: 179

This is the correct code:

updateDriverLocation(latitude, longitude, id:string)
{
   return this.DriverCollection.doc(id).update({
      location: new firebase.firestore.GeoPoint(latitude, longitude)
    });
}

Upvotes: 1

E. Sundin
E. Sundin

Reputation: 4180

updateDriverLocation(latitude, longitude, id: string) {
  return this.DriverCollection.doc(id).update({
    location: new firebase.firestore.GeoPoint(latitude, longitude);
  });
}

Here you're sending in an object to the update function:

{
        location: new firebase.firestore.GeoPoint(latitude, longitude);
      }

An object property can't end with ;

Instead the code should be:

updateDriverLocation(latitude, longitude, id: string) {
  return this.DriverCollection.doc(id).update({
    location: new firebase.firestore.GeoPoint(latitude, longitude)
  });
}

Upvotes: 2

Related Questions