Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project React REST API #16

Open
haydanu opened this issue Nov 21, 2019 · 1 comment
Open

Project React REST API #16

haydanu opened this issue Nov 21, 2019 · 1 comment

Comments

@haydanu
Copy link
Member

haydanu commented Nov 21, 2019

@lighteagle @iqbalmmm @robyafrizal

@haydanu
Copy link
Member Author

haydanu commented Nov 21, 2019

Task

  • Create project-rest-api-react in your local using npx create-react-app project-rest-api-react
  • Push to your GitHub repository and deploy to Netlify

Install dependencies needed to support this project

  • axios
  • react-router-dom
  • and anything you need

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

  • GET TODOS
axios.get(`https://cobacoba-hayepe.herokuapp.com/`)
      .then(result => console.log(result))
      .catch(error => console.log(error));
  };
  • GET SPECIFIC TODOS
// id = todos id
axios.get(`https://cobacoba-hayepe.herokuapp.com/${id}`)
      .then(result => console.log(result))
      .catch(error => console.log(error));
  };
  • ADD NEW TODOS
// 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));
  };
  • UPDATE TODOS
// 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));
  };
  • DELETE TODOS
// id = todos id to be deleted
axios.delete(`https://cobacoba-hayepe.herokuapp.com/${id}`)
      .then(result => console.log(result))
      .catch(error => console.log(error));
  };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment