undefined is not a function(evaluating 'start.getTime( )')


#1

Hey,
I’m using Pedometer Expo in my app which am developing.

  const end = new Date();
  const start = new Date();
    start.setDate(end.getDate() - 1);
    Pedometer.getStepCountAsync(start, end).then(
      result => {
        this.setState({ pastStepCount: result.steps });
      },
      error => {
        this.setState({
          pastStepCount: "Could not get stepCount: " + error
        });
      }
    );

this is the _subscribe( ) function which is as per the documentation.

I have changed the Date functions as below

    const startdate = new Date('July 4, 2018');
    const startdate1 = startdate.getDate();

    const enddate = new Date('July 5, 2018');
    const enddate1 = enddate.getDate();

I’m doing this to access the stepcount for a particular day ie . One day from jul 4 to jul 5(24 hours)
I’m able to access the pedometer, ie. as i use an android device, google fit is asking the permission to access the fitness data.
when i click allow, steps are being generated
but the below code shows an error

 <Text>
          Steps taken in the last 24 hours: {this.state.pastStepCount}
</Text>
const end = new Date();
const start = new Date();
    start.setDate(end.getDate() - 1);
    Pedometer.getStepCountAsync(start, end).then(
      result => {
        this.setState({ pastStepCount: result.steps });
      },
      error => {
        this.setState({
          pastStepCount: "Could not get stepCount: " + error
        });
      }
    );

this shows an error saying

Steps taken in the last 24 hours:Could not get stepCount : TypeError : undefined is not a function(evaluating 'start.getTime()' )

I haven’t used any getTime() methods but i still get that error.
can anyone help me with that.
thank you


#2

Hi there! Would you be willing to place a working reproduction of the issue into a snack at snack.expo.io? In general it will be much easier for people to help you quickly that way! Thanks :slight_smile:


#3

Hey,

snack example
above is the snack
can you please look into the issue.
thanks


closed #4

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.