Skip to content

Commit

Permalink
sleep time apres error message ou success message de l'ajout d'amis
Browse files Browse the repository at this point in the history
  • Loading branch information
lucas-science committed Apr 8, 2021
1 parent 2d06ac1 commit cfbaec7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .eslintcache

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions src/friends-liste.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ export default class friendsliste extends Component {
[name]: value
});
}

sleep = (milliseconds) => {
return new Promise(resolve => setTimeout(resolve, milliseconds))
}
// fonction permettant de faire une requête POST au serveur et d'envoyer les données
onSubmit = (event) => {
onSubmit = async (event) => {
event.preventDefault();
console.log("state envois demande amis : ",this.state)
// requête POST
Expand All @@ -58,6 +60,8 @@ export default class friendsliste extends Component {
console.log("erreur")
}
})
await this.sleep(3000)
this.setState({message:""});
}
componentDidMount(){
fetch('http://localhost:4000/app/friendlist', {
Expand Down

0 comments on commit cfbaec7

Please sign in to comment.