0

Trying to create a step tracking application, using ReactJS, where users can log in and compete one ageist the other, collect points, level up etc. Main information about steps should be taken from Google Fit API. The problem is that for some reason I keep getting empty array of points (There were some steps generated last week so it shouldn't be empty).

Response from API:

{
  "minStartTimeNs": "100000",
  "maxEndTimeNs": "1679904795000000",
  "dataSourceId": "derived:com.google.step_count.delta:com.google.android.gms:estimated_stepsltas",
  "point": []
}

My request:

 const listSteps = async () => {
    let response;
    try {
      const now = Date.now();

      response = await gapi.client.fitness.users.dataSources.datasets.get({
        userId: "me",
        dataTypeName: "com.google.step_count.delta",
        datasetId: `100000-${now}000000`,
        dataSourceId: "derived:com.google.step_count.delta:com.google.android.gms:estimated_stepsltas",
      });

      console.log("res", response);
    } catch (err) {
      console.log(err.message);
      return;
    }
  };

I've tried reading the Google Fit documentation, thought maybe the dataSourceId is wrong. Trued getting full dataSources object, to check if there is some kind of steps related data in there. No luck... Any ideas on what I'm doing wrong and why this might be happening?

  • can u try doing a post request to the api endpoint (instead of using the gapi) to see if u r getting the same dataset? - https://developers.google.com/fit/rest/v1/datasets#get_a_dataset . Do note dataset Id is in nanoseconds. – Someone Special Mar 27 '23 at 08:31
  • @SomeoneSpecial But your attached link uses the get method as well. And, just in case you didn't noticed in my example I am using nanoseconds :) – Little_bugfixer Mar 27 '23 at 08:45
  • it's using the get method, but it's gap vs using the api directly. secondly, you are using nanosecond but your startTime is not using nanosecond – Someone Special Mar 27 '23 at 08:57

0 Answers0