helpers/manageGarden.js
/**
 * Function to create a new garden
 * @param {json} values JSON-object of values passed to Garden-POST API
 * @returns {Promise<int>} ID of newly created garden, -1 for error
 */
Function to create a new garden
@param {json} values JSON-object of values passed to Garden-POST API
@returns {Promise} ID of newly created garden, -1 for error
Function to create a new garden @param { json } values JSON - object of values passed to Garden - POST API @returns { Promise } ID of newly created garden - 1 for error
async function createGarden(values) {
  const response = await fetch(gardenPostUrl, {
    method: "POST",
    headers: {
      "Content-Type": "application/json",
    },
    credentials: "include",
    body: JSON.stringify(values),
  });
  const content = await response.json();
  return new Promise((resolve, reject) => {
    if (response.status == 200) {
      resolve(content.id);
    } else {
      reject(-1);
    }
  });
}
async function createGarden ( values ) { const response = await fetch ( gardenPostUrl , { method : "POST" , headers : { "Content-Type" : "application/json" , } , credentials : "include" , body : JSON . stringify ( values ) , } ) ; const content = await response . json ( ) ; return new Promise ( ( resolve , reject ) => { if ( response . status == 200 ) { resolve ( content . id ) ; } else { reject ( - 1 ) ; } } ) ; }
Function to create a new garden
 @param {json} values JSON-object of values passed to Garden-POST API
 @returns {Promise<int>} ID of newly created garden, -1 for error
Function to create a new garden @param { json } values JSON - object of values passed to Garden - POST API @returns { Promise<int > } ID of newly created garden - 1 for error