GET

Let's now look at cURL commands to make HTTP requests. Depending on the state of your server, the output on making the GET Request might be different:

$ # List all books on server 
$ # Note that we use '-L' flag while using cURL. 
$ # This takes care of any http redirections that might be required. 
$ curl -L localhost:8080/api/books | jq  # GET CALL 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
                                 Dload  Upload   Total   Spent    Left  Speed 
100    46  100    46    0     0   9721      0 --:--:-- --:--:-- --:--:-- 11500 
100   311  100   311    0     0  59589      0 --:--:-- --:--:-- --:--:-- 59589 
[ 
  { 
    "id": "3", 
    "title": "Book-3", 
    "link": "http://link-to-book3.com" 
  }, 
  { 
    "id": "4", 
    "title": "Book-4", 
    "link": "http://link-to-book4.com" 
  }, 
  { 
    "id": "5", 
    "title": "Book-5", 
    "link": "http://link-to-book5.com" 
  }, 
  { 
    "id": "1", 
    "title": "Book-1", 
    "link": "http://link-to-book1.com" 
  }, 
  { 
    "id": "2", 
    "title": "Book-2", 
    "link": "http://link-to-book2.com" 
  } 
] 
 
$ curl localhost:8080/api/books/3 | jq  # GET a single resource. 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current 
                                 Dload  Upload   Total   Spent    Left  Speed 
100    61  100    61    0     0  13255      0 --:--:-- --:--:-- --:--:-- 15250 
{ 
  "id": "3", 
  "title": "Book-3", 
  "link": "http://link-to-book3.com" 
} 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.144.170