helpers/manageGarden.js
/**
 *
 * @param {json} user JSON-object of the current user, like it is returned from the User-API
 * @param {*} gardenId ID of the garden, from which a user likes to un-register
 * @returns {Promise<boolean>} Indicates, whether leaving the garden was successful
 */
@param {json} user JSON-object of the current user, like it is returned from the User-API
@param {*} gardenId ID of the garden, from which a user likes to un-register
@returns {Promise} Indicates, whether leaving the garden was successful
@param { json } user JSON - object of the current user like it is returned from the User - API @param { * } gardenId ID of the garden from which a user likes to un - register @returns { Promise } Indicates whether leaving the garden was successful
async function leaveGarden(user, gardenId) {
  delete user["email"];
  delete user["id"];
  user["garden"] = user["garden"].filter((item) => item !== parseInt(gardenId));
  const response = await fetch(userPutUrl, {
    method: "PUT",
    headers: {
      "Content-Type": "application/json",
    },
    credentials: "include",
    body: JSON.stringify(user),
  });
  return new Promise((resolve, reject) => {
    if (response.status == 200) {
      resolve(true);
    } else {
      reject(false);
    }
  });
}
async function leaveGarden ( user , gardenId ) { delete user [ "email" ] ; delete user [ "id" ] ; user [ "garden" ] = user [ "garden" ] . filter ( ( item ) => item !== parseInt ( gardenId ) ) ; const response = await fetch ( userPutUrl , { method : "PUT" , headers : { "Content-Type" : "application/json" , } , credentials : "include" , body : JSON . stringify ( user ) , } ) ; return new Promise ( ( resolve , reject ) => { if ( response . status == 200 ) { resolve ( true ) ; } else { reject ( false ) ; } } ) ; }
@param {json} user JSON-object of the current user, like it is returned from the User-API
 @param {*} gardenId ID of the garden, from which a user likes to un-register
 @returns {Promise<boolean>} Indicates, whether leaving the garden was successful
@param { json } user JSON - object of the current user like it is returned from the User - API @param { * } gardenId ID of the garden from which a user likes to un - register @returns { Promise<boolean > } Indicates whether leaving the garden was successful