An Interest In:
Web News this Week
- April 2, 2024
- April 1, 2024
- March 31, 2024
- March 30, 2024
- March 29, 2024
- March 28, 2024
- March 27, 2024
January 9, 2022 04:19 pm GMT
Original Link: https://dev.to/codewithsnowbit/how-to-make-http-requests-using-fetch-1hj8
How to make HTTP requests using "fetch"
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
Original Link: https://dev.to/codewithsnowbit/how-to-make-http-requests-using-fetch-1hj8
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To