I have written a javascript command with the help of Chat GPT3 (I am not a developer) but would love some community assistance here! I'm looking to import activity data from Strava into an Equals spreadsheet.
Can someone help me understand what I need to do to fix this? Any support is very appreciated!
Here's what I have:
const equals = require("equals");
const axios = require("axios");
const STRAVA_ACCESS_TOKEN = equals.getSecret("strava_api_key");
const STRAVA_ATHLETE_ID = equals.getSecret("strava_athlete_id");
const TABLE_NAME = "Activities";
const postData = async () => {
const resp = await axios({
method: "post",
url: `https://www.strava.com/api/v3/athletes/${STRAVA_ATHLETE_ID}/activities`,
headers: {
Authorization: `Bearer ${STRAVA_ACCESS_TOKEN}`
}
});
return resp.data;
};
const data = await postData();
equals.addHeaders(["Name", "Sport Type", "Elapsed Time", "Description", "Distance"]);
for(const record of data) {
equals.addRow([
record.name,
record.sport_type,
record.elapsed_time,
record.description,
record.distance
]);
}