Skip to content

Instantly share code, notes, and snippets.

@edilson
Created September 23, 2021 20:04
Show Gist options
  • Save edilson/99829836759df3ccce77e821a5bda490 to your computer and use it in GitHub Desktop.
Save edilson/99829836759df3ccce77e821a5bda490 to your computer and use it in GitHub Desktop.
Strava upload sample NodeJS
const body = new FormData();
body.append('data_type', 'gpx');
body.append('name', activity_name);
body.append('external_id', activity_id);
body.append('file', fs.readFileSync(gpxFilePath, { encoding: 'utf8' }), {
contentType: 'application/gpx+xml',
});
const stravaUploadResponse = await fetch(
'https://www.strava.com/api/v3/uploads',
{
method: 'POST',
headers: {
Authorization: `Bearer a315ac2e1e868c5b8c4a5ad00ae243579ab3d323`,
'Content-Type': 'multipart/form-data',
},
body,
}
).then(response => response.json());
console.log(stravaUploadResponse);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment