Post data not getting into MongoDB


#1

How do I send data into MongoDB from Ionic/Angular 2.
I do get the json forma data displayed in console log, but have difficulties getting the data into the database.

This is the .js file-

import { Component } from ‘@angular/core’;
import { Geolocation } from ‘@ionic-native/geolocation’;
import { NavController, Platform} from ‘ionic-angular’;
import { ViewController } from ‘ionic-angular’;

@Component({
selector: ‘about’,
templateUrl: ‘about.html’

})
export class AboutPage {

constructor(public navCtrl: NavController, public viewCtrl: ViewController, private platform: Platform, private geo: Geolocation) {

console.log("Hello from about page constructor");

} // end of constructor

busData = {latitude: null,
longitude: null,
timestamp: null,
//seatedstanding: ‘’
}

/* logForm defined in the .html file */
logForm() {

this.geo.getCurrentPosition().then(data => {
  this.busData.latitude = data.coords.latitude;
  this.busData.longitude = data.coords.longitude;
  this.busData.timestamp = data.timestamp;

  console.log(this.busData);

  busData.save().then(function(busData) {
  db.collection.save(
  busData )
      
    });

} // end of class