Outline
The current standard for making HTTP requests in Deno scripts is to use the fetch
API. You can check out the documentation to see how to use it, but it's a widely used library for front end applications.
fetch
requests return promises, so you can use .then
callbacks, or use the async await
format, or you can use top level await
, which means you don't need to use await
inside a function marked as async
.
For this assignment, make a GET request to the JSON placeholder users API to get a user. Output the user's name, email address, and username to the console. For some bonus, POST a request to create a new user.
GET request URL: https://jsonplaceholder.typicode.com/users/1
POST request URL: https://jsonplaceholder.typicode.com/users