0

I am trying to pull resting heart rate data from the jawbone server via javascript/node.js. I keep getting can not read property get. This is the part of my code that causes the error. It seems I do not have the correct naming convention to receiver resting heart rate

up.heartrates.get({}, function(err, body) {
    if (err) {
        console.log('Error receiving Jawbone UP data');
    } else {
        jawboneDataheart = JSON.parse(body).data;

        for (i = 0; i < jawboneDataheart.items.length; i++) {
                date = jawboneDataheart.items[i].date.toString(),
                year = date.slice(0,4),
                month = date.slice(4,6),
                day = date.slice(6,8);


            jawboneDataheart.items[i].date = month + '/' + day + '/' + year;
            jawboneDataheart.items[i].title = jawboneDataheart.items[i].title.replace('for ', '');


    }}});
  • Could you include the actual request you make to the server? Have you looked at the raw response? You should be able to read the JSON that comes back. – RAY Aug 03 '16 at 20:59
  • I'm not receiving data...I get this error:...............................................................TypeError: Cannot read property 'get' of undefined at OAuth2Strategy._verify (C:\jawbone\heartonly.js:85:17) at C:\jawbone\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:195:22 at OAuth2Strategy.userProfile (C:\jawbone\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:244:10) at loadIt (C:\jawbone\node_modules\passport-oauth\node_modules\passport-oauth2\lib\strategy.js:314:17) at OAuth2Strategy._loadUserProfile – Dennis Chase Aug 04 '16 at 15:42
  • That looks like it's failing in the javascript and not even issuing a request. Do you see a request to the UP APIs? I googled your error message and this might be helpful: http://stackoverflow.com/questions/24478293/cannot-read-property-get-of-undefined-with-angular (however it is lower-level than what you've paste above). – RAY Aug 04 '16 at 15:54
  • it seems to work fine for moves and sleeps...but heartrates is failing. – Dennis Chase Aug 05 '16 at 00:10
  • Interesting. It's hard for me to interpret that error message without seeing the code. Again, do you see it actually issuing a request to the API and a response coming back? If it's working for moves and sleeps maybe it's a scope issue, did you authenticate the user with the heartrate_read scope? – RAY Aug 05 '16 at 16:11

0 Answers0