mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-13 18:24:58 +00:00
35 lines
774 B
JavaScript
35 lines
774 B
JavaScript
/*
|
|
* GET a person by id
|
|
*/
|
|
const getPerson = (id) => {
|
|
const url = `/api/1.0/person/person/${id}.json`;
|
|
return fetch(url)
|
|
.then(response => {
|
|
if (response.ok) { return response.json(); }
|
|
throw Error('Error with request resource response');
|
|
});
|
|
};
|
|
|
|
/*
|
|
* POST a new person
|
|
*/
|
|
const postPerson = (body) => {
|
|
const url = `/api/1.0/person/person.json`;
|
|
return fetch(url, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json;charset=utf-8'
|
|
},
|
|
body: JSON.stringify(body)
|
|
})
|
|
.then(response => {
|
|
if (response.ok) { return response.json(); }
|
|
throw Error('Error with request resource response');
|
|
});
|
|
};
|
|
|
|
export {
|
|
getPerson,
|
|
postPerson
|
|
};
|