tp4
This commit is contained in:
35
R4.01_R4.A.10/td_tp/tp4/aide.md
Normal file
35
R4.01_R4.A.10/td_tp/tp4/aide.md
Normal file
@@ -0,0 +1,35 @@
|
||||
#### XMLHttpRequest
|
||||
```js
|
||||
let xhr = new XMLHttpRequest()
|
||||
xhr.open("GET","mon/url")
|
||||
|
||||
xhr.onload = ...
|
||||
xhr.onerror = ...
|
||||
|
||||
xhr.send()
|
||||
```
|
||||
#### Promise
|
||||
```js
|
||||
|
||||
let promise = new Promise ((resolve,reject) => {
|
||||
setTimeout(() => {
|
||||
resolve("OK")
|
||||
},1000)
|
||||
})
|
||||
promise.then(data => ....)
|
||||
```
|
||||
|
||||
#### async/await
|
||||
|
||||
```js
|
||||
|
||||
function getUser(email){
|
||||
return new Promise(...)
|
||||
}
|
||||
|
||||
async function updateUser(){
|
||||
|
||||
let user = await getUser(...)
|
||||
console.log(user)
|
||||
}
|
||||
```
|
||||
Reference in New Issue
Block a user