
import { request } from './request';

const URL = '/gardens';

export default {
    add(plant) {
        return request.post(`${URL}/${plant._id}`);
    }
}
@@ -82,70 +82,1796 @@
     
-add(plant) %7B%0A        return request.post(%60$%7BURL%7D/$%7Bplant._id%7D%60
+getAll() %7B%0A        return request.get(URL) %0A            .then(%0A                r =%3E r.body,%0A                (%7B response %7D) =%3E %7B%0A                    const %7B body, text %7D = response;%0A                    const error = body ? body.message %7C%7C body.error %7C%7C body : text;%0A                    throw error;%0A                %7D%0A            );%0A    %7D,%0A%0A    get(id) %7B%0A        return request.get(%60$%7BURL%7D/$%7Bid%7D%60)%0A            .then(%0A                r =%3E r.body,%0A                (%7B response %7D) =%3E %7B%0A                    const %7B body, text %7D = response;%0A                    const error = body ? body.message %7C%7C body.error %7C%7C body : text;%0A                    throw error;%0A                %7D%0A            );%0A    %7D,%0A%0A%0A%0A    add(garden) %7B%0A        return request.post(URL, garden)%0A            .then(%0A                r =%3E r.body,%0A                (%7B response %7D) =%3E %7B%0A                    const %7B body, text %7D = response;%0A                    const error = body ? body.message %7C%7C body.error %7C%7C body : text;%0A                    throw error;%0A                %7D%0A            );%0A    %7D,%0A%0A    update(garden) %7B%0A        return request.put(%60$%7BURL%7D/$%7Bgarden._id%7D%60, garden)%0A            .then(%0A                r =%3E r.body,%0A                (%7B response %7D) =%3E %7B%0A                    const %7B body, text %7D = response;%0A                    const error = body ? body.message %7C%7C body.error %7C%7C body : text;%0A                    throw error;%0A                %7D%0A            );%0A    %7D,%0A%0A    delete(garden) %7B%0A        return request.delete(%60$%7BURL%7D/$%7Bgarden._id%7D%60)%0A            .then(%0A                r =%3E r.body,%0A                (%7B response %7D) =%3E %7B%0A                    const %7B body, text %7D = response;%0A                    const error = body ? body.message %7C%7C body.error %7C%7C body : text;%0A                    throw error;       %0A                %7D%0A            
 );%0A 
@@ -1876,8 +1876,9 @@
 %0A    %7D%0A%7D
+;

Complete gardensApi.js