Skip to content

Commit 059ea5d

Browse files
committed
adding lessons
1 parent 1a13dac commit 059ea5d

File tree

41 files changed

+226
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+226
-28
lines changed

lessons/02-promises/lecture/NOTES.md

Lines changed: 1 addition & 1 deletion
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ function signup(user: User) {
1414
signup({ name: 'brad' }).then(() => {
1515
console.log('✅ User Added')
1616
})
17+
18+
// Remember "top-level" await

lessons/03-async-await/practice/index.final.ts renamed to lessons/04-async-await/practice/index.final.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async function main() {
3434

3535
// async function getPersonVehicles(id: number): Promise<string[]> {
3636
// const response = await fetch(`https://swapi.dev/api/people/${id}`)
37-
// const person = await response.json()
37+
// const person = await response.json() as Record<string, any>
3838

3939
// // The above could also be written as
4040
// // const person = await fetch(`https://swapi.dev/api/people/${id}`).then((response) => response.json())
@@ -74,7 +74,7 @@ async function main() {
7474
// async function getPersonVehicles(id: number): Promise<string[]> {
7575
// const person = await fetch(`https://swapi.dev/api/people/${id}`).then((response) =>
7676
// response.json()
77-
// )
77+
// ) as Record<string, any>
7878
// return person.vehicles
7979
// }
8080

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ main()
77
Practice: 1
88
*****************************************/
99

10-
function wait(ms: number) {
11-
return new Promise((resolve) => {
12-
setTimeout(resolve, ms)
13-
})
14-
}
10+
// function wait(ms: number) {
11+
// return new Promise((resolve) => {
12+
// setTimeout(resolve, ms)
13+
// })
14+
// }
1515

16-
// Re-write main to use async/await
16+
// // Re-write main to use async/await
1717

18-
function main() {
19-
wait(1000).then(() => {
20-
console.log('Wait for one second')
21-
})
22-
}
18+
// function main() {
19+
// wait(1000).then(() => {
20+
// console.log('Wait for one second')
21+
// })
22+
// }
2323

2424
/****************************************
2525
Practice: 2
@@ -33,7 +33,7 @@ function main() {
3333

3434
// function getPersonVehicles(id: number): Promise<string[]> {
3535
// return fetch(`https://swapi.dev/api/people/${id}`)
36-
// .then((response) => response.json())
36+
// .then((response) => response.json() as Record<string, any>)
3737
// .then((person) => person.vehicles)
3838
// }
3939

@@ -71,9 +71,9 @@ function main() {
7171
// }
7272

7373
// async function getPersonVehicles(id: number): Promise<string[]> {
74-
// const person = await fetch(`https://swapi.dev/api/people/${id}`).then((response) =>
74+
// const person = (await fetch(`https://swapi.dev/api/people/${id}`).then((response) =>
7575
// response.json()
76-
// )
76+
// )) as Record<string, any>
7777
// return person.vehicles
7878
// }
7979

0 commit comments

Comments
 (0)