fetch post resource

This commit is contained in:
2021-05-13 10:05:08 +02:00
parent 87e2ac9386
commit aef97cca32
4 changed files with 39 additions and 36 deletions

View File

@@ -1,5 +1,5 @@
const getBodyTypeId = (payload) => {
const getEntityTypeId = (payload) => {
const body = {};
if (payload !== null) {
body['type'] = payload.type;
@@ -56,7 +56,7 @@ const patchAccompanyingCourse = (id, body) => {
* @method string - POST or DELETE
*/
const postParticipation = (id, payload, method) => {
const body = getBodyTypeId(payload);
const body = getEntityTypeId(payload);
const url = `/api/1.0/person/accompanying-course/${id}/participation.json`;
return fetch(url, {
method: method,
@@ -80,7 +80,7 @@ const postParticipation = (id, payload, method) => {
* @method string - POST or DELETE
*/
const postRequestor = (id, payload, method) => {
const body = getBodyTypeId(payload);
const body = getEntityTypeId(payload);
const url = `/api/1.0/person/accompanying-course/${id}/requestor.json`;
return fetch(url, {
method: method,
@@ -104,7 +104,14 @@ const postRequestor = (id, payload, method) => {
* @method string - POST or DELETE
*/
const postResource = (id, payload, method) => {
const body = getBodyTypeId(payload);
console.log('payload', payload);
const body = { type: "accompanying_period_resource" };
if (method === 'DELETE') {
body['id'] = payload.id;
} else {
body['resource'] = getEntityTypeId(payload);
}
console.log('body', body);
const url = `/api/1.0/person/accompanying-course/${id}/resource.json`;
return fetch(url, {
method: method,