Create new bikes!

This commit is contained in:
Drew Larson
2017-05-23 19:30:44 -06:00
parent 780825b828
commit e061320ee7
5 changed files with 72 additions and 16 deletions
@@ -28,8 +28,8 @@ const Api = {
throw error;
});
},
saveBike(data) {
return fetch(`/api/v1/bikes/${data.id}/`, {
updateBike(data) {
return fetch(data.url, {
credentials: 'same-origin',
method: 'PUT',
headers,
@@ -43,6 +43,21 @@ const Api = {
throw error;
});
},
saveBike(data) {
return fetch(`/api/v1/bikes/`, {
credentials: 'same-origin',
method: 'POST',
headers,
body: JSON.stringify(data),
})
.then(checkStatus)
.then(parseJson)
.then(data => data)
.catch((error) => {
console.log('request failed', error);
throw error;
});
},
};
export default Api;