I am using the FitBit API for my senior project and I keep getting the "The API you are requesting could not be found." error. I am using the fitbit-node package, and here is the section causing the error:
router.get('/test', function(req, res) {
if (req.session.authorized) {
client.get('/1/user/-/activities/date/today.json', req.session.access_token).then(function(results) {
res.json(results[0]);
});
} else {
res.status(403);
res.json({
errors: [{
message: 'not authorized'
}]
});
}
});
I am trying to access the /1/user/-/activities/date/today.json endpoint, but keep getting the error. I cannot access any other endpoint except /profile.json. The req.session.access_token is the stored access token from authentication. I am using the same set-up for /profile.json.
I'm following examples from this repo and cannot figure out why it is not working: https://github.com/lukasolson/fitbit-node/blob/master/example.js
Thanks!
Remove the /1/user/-
in the path. It is already in the client.
router.get('/test', function(req, res) {
if (req.session.authorized) {
client.get('/activities/date/today.json', req.session.access_token).then(function(results) {
res.json(results[0]);
});
} else {
res.status(403);
res.json({
errors: [{
message: 'not authorized'
}]
});
}
});