We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5a86e5c commit 13c382dCopy full SHA for 13c382d
README.md
@@ -505,41 +505,5 @@ function isJson(str) {
505
}
506
```
507
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
-```
544
545
0 commit comments