1
+ //npm install axios
1
2
import React , { Component } from "react" ;
2
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
3
- import { Link } from 'react-router-dom' ;
3
+ import { axios } from 'axios' ;
4
4
5
- import api from "../../api" ;
6
5
7
6
class APITodo extends Component {
8
7
constructor ( props ) {
@@ -13,13 +12,14 @@ class APITodo extends Component {
13
12
}
14
13
15
14
componentDidMount ( ) {
16
- const todoId = this . props . match . params ;
17
- api . todos ( ) . getOne ( todoId )
15
+ const id = "your id like 1245" ;
16
+ axios . get ( "your api endpoint route" , id )
18
17
. then ( response => this . setState ( { todo : response . data } ) ) ;
19
18
}
20
19
onDelete = ( ) => {
21
- const todoId = this . props . match . params ;
22
- api . todos ( ) . delete ( todoId )
20
+ // const todoId = this.props.match.params;
21
+ const todoId = "your deleted id like 123" ;
22
+ axios . delete ( "your api endpoint route" , id ) //id for specific data delete
23
23
. then ( response => this . props . history . push ( '/' ) ) ;
24
24
}
25
25
@@ -31,10 +31,7 @@ class APITodo extends Component {
31
31
< div className = "row mt-5" >
32
32
< div className = "col-lg-8 offset-lg-2" >
33
33
< h4 > { todo . title }
34
- < Link to = { `/todo/edit/${ todo . _id } ` } >
35
- < FontAwesomeIcon icon = "edit" className = "ml-5" />
36
- </ Link >
37
- < FontAwesomeIcon icon = "trash" onClick = { this . onDelete } className = "float-right mr-5" />
34
+
38
35
</ h4 >
39
36
< p > { todo . body } </ p >
40
37
</ div >
0 commit comments