-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAsync.js
More file actions
59 lines (48 loc) · 1.55 KB
/
Async.js
File metadata and controls
59 lines (48 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// // // // setTime()
// // // const sayAdnan = () => {
// // // console.log("Adnan Jamil");
// // // }
// // // const changeText = () => {
// // // document.querySelector('h1').innerHTML = "My Name is Muhamamd Adnan"
// // // console.log(changeMe())
// // // }
// // // const changeMe = setTimeout(changeText() , 2000)
// // // document.querySelector('#stop').addEventListener('click', () =>{
// // // clearTimeout(changeMe)
// // // console.log("stoped")
// // // })
// // async function fetchData(){
// // const result = await fetchData('https://api.example.com/data')
// // const data = await result.json();
// // console.log(data);
// // } catch (eror){
// // }
// // async function is always return promises
// async function test(){
// const response = await fetch("https://jsonplaceholder.typicode.com/todos/1")
// const data = await response.json()
// return data
// }
// test().then((res)=>{
// console.log(res);
// }).catch((error)=>{
// console.log(error);
// })
// async function newData(){
// const apiData = await fetch("https://jsonplaceholder.typicode.com/todos/1")
// const data = await apiData.json()
// return data
// }
// newData().then((res)=>{
// console.log(res);
// }).catch((eror)=>{
// console.log(eror);
// })
async function multipleAPi(){
const newApi = await fetch("https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/usd.json")
const currencyData = await newApi.json()
return currencyData
}
multipleAPi().then((res)=>{
console.log(res);
})