How to make HTTP requests using "fetch"

I am 17 years old and a young passionate and self-taught frontend web developer and have an intention to become a successful developer. I usually write about JavaScript and Web Development and share some tips in the articles.
Hello π
Method 1 - Promise
fetch('https://randomuser.me/api/')
.then(res => res.json())
.then(data => {
console.log(data)
})
Method 2 - Async
const response = await fetch('https://randomuser.me/api/')
const data = response.json()
console.log(data)
Note: Make sure function is async
Thank you for reading
- Follow me on Twitter - @codewithsnowbit
- Subscribe me on YouTube - Code With SnowBit




