Admin: sports edition
This commit is contained in:
@ -2,8 +2,8 @@ import { apiUrl } from '../utils'
|
||||
|
||||
export default class MpwoApi {
|
||||
|
||||
static getData(target) {
|
||||
const request = new Request(`${apiUrl}${target}`, {
|
||||
static getData(target, id = null) {
|
||||
const request = new Request(`${apiUrl}${target}${id ? `/${id}` : ''}`, {
|
||||
method: 'GET',
|
||||
headers: new Headers({
|
||||
'Content-Type': 'application/json',
|
||||
@ -14,4 +14,18 @@ export default class MpwoApi {
|
||||
.then(response => response.json())
|
||||
.catch(error => error)
|
||||
}
|
||||
|
||||
static updateData(target, data) {
|
||||
const request = new Request(`${apiUrl}${target}/${data.id}`, {
|
||||
method: 'PATCH',
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user