FitTrackee/mpwo_client/src/mwpoApi/activities.js

45 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-05-01 19:29:21 +02:00
import { apiUrl } from '../utils'
export default class MpwoApi {
static addActivity(formData) {
const request = new Request(`${apiUrl}activities`, {
method: 'POST',
headers: new Headers({
Authorization: `Bearer ${window.localStorage.getItem('authToken')}`,
}),
body: formData,
})
return fetch(request)
.then(response => response.json())
.catch(error => error)
}
2018-05-08 18:20:41 +02:00
static addActivityWithoutGpx(data) {
const request = new Request(`${apiUrl}activities/no_gpx`, {
method: 'POST',
headers: new Headers({
'Content-Type': 'application/json',
Authorization: `Bearer ${window.localStorage.getItem('authToken')}`,
}),
body: JSON.stringify(data)
})
return fetch(request)
.then(response => response.json())
.catch(error => error)
}
2018-05-03 21:42:54 +02:00
static getActivityGpx(activityId) {
const request = new Request(`${apiUrl}activities/${activityId}/gpx`, {
method: 'GET',
headers: new Headers({
Authorization: `Bearer ${window.localStorage.getItem('authToken')}`,
}),
})
return fetch(request)
.then(response => response.json())
.catch(error => error)
}
2018-05-01 19:29:21 +02:00
}