Created
September 23, 2021 20:04
-
-
Save edilson/99829836759df3ccce77e821a5bda490 to your computer and use it in GitHub Desktop.
Strava upload sample NodeJS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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