Alternatively, we can make GET requests using curl. Curl, short for Client for URLs, is a command line tool that allows us to transfer data to and from a server. It supports multiple protocols, including HTTP. You can read more about curl in our “What is curl?” article.
Curl is also useful for testing HTTP request methods from your local command line. Let’s say we want to test the HTTP endpoint
http://www.mypetclinic.com/dogs/. We would use the curl command…
…which uses the GET request as the default method to retrieve the
dogs resource from that URL; the
dogs resource is displayed in the terminal rather than the browser. In doing so, we again confirm that our server is returning and displaying the information that we expect it to.
Again, let’s confirm that our restaurant app’s GET request is working by hitting the endpoint – this time, with a curl command:
You should see similar output as before.