impactbyte-komodo / Projects

https://gitlab.com/impactbyte/learn/course-fullstackweb
0 stars 0 forks source link

Project React REST API #16

Open haydanu opened 4 years ago

haydanu commented 4 years ago

@lighteagle @iqbalmmm @robyafrizal

haydanu commented 4 years ago

Task

Install dependencies needed to support this project

Rules

API Endpoints

HTTP Routes Description
GET / to get all todos
GET /:id to get each todo
PUT /:id to update specific todo
DELETE /:id to delete specific todo
POST / to post new todo

USAGE

Please install axios first before using it

axios.get(`https://cobacoba-hayepe.herokuapp.com/`)
      .then(result => console.log(result))
      .catch(error => console.log(error));
  };
// id = todos id
axios.get(`https://cobacoba-hayepe.herokuapp.com/${id}`)
      .then(result => console.log(result))
      .catch(error => console.log(error));
  };
// just need to pass todo to body
// id, isEdit and status is set to default

axios.post(`https://cobacoba-hayepe.herokuapp.com`, {
    todo: your_todo // your todo value
})
      .then(result => console.log(result))
      .catch(error => console.log(error));
  };
// have to fill body with your todo and status

axios.put(`https://cobacoba-hayepe.herokuapp.com`, {
    todo: your_todo,
    status: your_todo_status // 0 for false and 1 for true
})
      .then(result => console.log(result))
      .catch(error => console.log(error));
  };
// id = todos id to be deleted
axios.delete(`https://cobacoba-hayepe.herokuapp.com/${id}`)
      .then(result => console.log(result))
      .catch(error => console.log(error));
  };