Skip to content

Commit 13c382d

Browse files
authored
removed react fetch API data snippet
removed react snippet and moved to ReactCodeSnippet.md file
1 parent 5a86e5c commit 13c382d

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

README.md

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -505,41 +505,5 @@ function isJson(str) {
505505
}
506506
```
507507
508-
# Fetch data from API REACT
509-
``` REACT JS
510-
import React, {Component} from 'react'
511-
512-
export default class StarWars extends Component {
513-
constructor(){
514-
super()
515-
this.state = {
516-
character: {},
517-
isLoading: false
518-
}
519-
}
520-
521-
componentDidMount(){
522-
this.setState({isLoading: true})
523-
fetch("https://swapi.co/api/people/1")
524-
.then(response => response.json())
525-
.then(data => (
526-
this.setState({
527-
isLoading: false,
528-
character: data
529-
})
530-
))
531-
}
532-
533-
534-
render(){
535-
const text = this.state.isLoading ? "People data is loading..." : this.state.character.name
536-
return(
537-
<div>
538-
<p>{text}</p>
539-
</div>
540-
)
541-
}
542-
}
543-
```
544508
545509

0 commit comments

Comments
 (0)