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
Top comments (0)