Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const fs = require('fs')
const strava = require('strava-v3')
strava.athlete.listActivities({
'per_page': 200
}, (err, payload, limits) => {
if (!err) {
console.log('start read save file')
fs.writeFile('records.json', JSON.stringify(payload, null, 2), function (err) {
if (err) return console.log(err)
console.log('success save file')
})
}
else {
console.log(err);
}
})
exports.getActivities = function(next) {
var cachedResult = cache.get('strava.getActivities');
if (cachedResult) {
return q.fcall(function() {
return cachedResult;
});
}
var deferred = q.defer();
strava.athlete.listActivities({ 'access_token': process.env.STRAVA_ACCESS_TOKEN }, function(err, response) {
if (err) {
deferred.reject(next(new Error('Failed to retrieve Strava activities')));
}
var payload = response;
var data = [];
for (var i = 0; i < payload.length; i++)
{
var item = payload[i];
data.push({
dateTime: new Date(item['start_date']),
name: item['name'],
type: item['type'],
distance: item['distance'],