Admin: add and delete a sport (WIP)

This commit is contained in:
Sam
2018-04-30 21:38:09 +02:00
parent b69a55362d
commit e423c355b5
10 changed files with 256 additions and 47 deletions

View File

@ -15,6 +15,20 @@ export default class MpwoApi {
.catch(error => error)
}
static addData(target, data) {
const request = new Request(`${apiUrl}${target}`, {
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)
}
static updateData(target, data) {
const request = new Request(`${apiUrl}${target}/${data.id}`, {
method: 'PATCH',
@ -28,4 +42,17 @@ export default class MpwoApi {
.then(response => response.json())
.catch(error => error)
}
static deleteData(target, id) {
const request = new Request(`${apiUrl}${target}/${id}`, {
method: 'DELETE',
headers: new Headers({
'Content-Type': 'application/json',
Authorization: `Bearer ${window.localStorage.getItem('authToken')}`,
}),
})
return fetch(request)
.then(response => response)
.catch(error => error)
}
}