Getting ready

To test this recipe, you will need a way to easily send HTTP requests. An excellent free tool for this is Postman (https://www.getpostman.com/), which features a nice and self-explanatory UI. If you'd rather not download anything, you can use your terminal for this. If you're on Windows, you can open PowerShell and enter the following to do an HTTP request:

Invoke-WebRequest -UseBasicParsing <Your URL> -Method <Your method in CAPSLOCK> -Body <Your message as a string>

So, if you wanted to POST the message hello there, my echoing friend to http://localhost:3000/echo, as you will be asked to later in the recipe, you'd need to enter the following command:

Invoke-WebRequest -UseBasicParsing http://localhost:3000/echo -Method POST -Body "Hello there, my echoing friend"

On Unix systems, you can use cURL for that (https://curl.haxx.se/). The analog command is the following:

curl -X <Your method> --data <Your message> -g <Your URL>

cURL will resolve localhost to its entry in /etc/hosts. In some configurations, this will only be the IPv4 loopback address (127.0.0.1). In some others, you will have to use ip6-localhost. Check your /etc/hosts to find out what to use. In any case, an explicit [::1] will always work. As an example, the following command will again POST the message hello there, my echoing friend to http://localhost:3000/echo:

curl -X POST --data "Hello there my echoing friend" -g "http://[::1]:3000/echo"
..................Content has been hidden....................

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