mirror of
https://github.com/fspc/workstand.git
synced 2026-09-17 00:51:39 -04:00
Edit bikes.
This commit is contained in:
@@ -1,4 +1,8 @@
|
||||
import fetch from 'isomorphic-fetch';
|
||||
import Cookies from 'js-cookie';
|
||||
|
||||
const csrfToken = Cookies.get('csrftoken')
|
||||
const headers = new Headers({ 'X-CSRFToken': csrfToken, 'Content-Type': 'application/json' });
|
||||
|
||||
const checkStatus = (response) => {
|
||||
if (response.status >= 200 && response.status < 300) {
|
||||
@@ -24,10 +28,12 @@ const Api = {
|
||||
throw error;
|
||||
});
|
||||
},
|
||||
saveBike(id) {
|
||||
return fetch(`/api/v1/bike/${id}`, {
|
||||
saveBike(data) {
|
||||
return fetch(`/api/v1/bikes/${data.id}/`, {
|
||||
credentials: 'same-origin',
|
||||
method: 'PUT',
|
||||
headers,
|
||||
body: JSON.stringify(data),
|
||||
})
|
||||
.then(checkStatus)
|
||||
.then(parseJson)
|
||||
|
||||
Reference in New Issue
Block a user