import React, { Component } from 1 react1; import "./App.css" class Home extends Component { url = "http://localhost:8001/courses/" state = { show: false, data:[], rating: } componentDidMount = () => { this.handleGetData() } handleGetData = () => { fetch(this.url + "get") .then((res) => res.json()) .then((json) => { this.setState({ data: json }) }) } handleApply = async (id) => { const requestoption = { method: ’post1, headers: { ’Content-Type1: 1 application/json’ } }; fetch(this.url + 'enroll/' + id, requestoption) •then(() => { this.handleGetData() }) }; handleRating = (e) => { this.setState({ rating: e.target.value }) } handleAddRating = async (id) => { const requestoption = { method: 'PATCH', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ rating: this.state.rating }) } fetch(this.url + "rating/" + id, requestoption) •then(() => { this.handleGetData() }) } handleDrop = async (id) => { const requestoption = { method: 'DELETE', headers: { 'Content-Type': 'application/json' }, }; fetch(this.url + "drop/" + id, requestoption) •then(() => { this.handleGetData() }) } render() { return (

ABC Learning

{this.state.data.map(courses => { return (
  • {courses.courseName}
  • {courses.courseDept}
  • {courses.description}
  • {courses.isApplied &&
  • {!courses.isRated &&
  • Rate:
  • } {courses.isApplied && ~ } } {1 courses.isApplied && this.handleApply(courses._id)}>Apply }
  • {courses.duration} hrs . {courses.noOfRatings} Ratings . {courses.rating}/5
); } } export default Home