Skip to content

Instantly share code, notes, and snippets.

@edilson
Created September 24, 2021 18:48
Show Gist options
  • Save edilson/8b6e316eba5e7251f32c343291ec8ffa to your computer and use it in GitHub Desktop.
Save edilson/8b6e316eba5e7251f32c343291ec8ffa to your computer and use it in GitHub Desktop.
const body = new FormData();
body.append('name', activity_name);
body.append('data_type', 'gpx');
body.append('external_id', activity_id);
body.append(
'file',
Buffer.from(gpxFileString, 'utf-8'),
`activity_${activity_id}.gpx`
);
const stravaUploadResponse = await fetch(
'https://www.strava.com/api/v3/uploads',
{
method: 'POST',
headers: {
Authorization: `Bearer ${newTokens.access_token}`,
...body.getHeaders(),
},
body,
}
).then(response => response.json());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment