Dispatch is a library for asynchronous HTTP interaction. It allows us to make asynchronous Http request to the url. If there is a REST API, and you want to hit it from your code, its the thing that you are looking for.
For getting started, you have to add its dependency inside the build.sbt
Now you are good to go to use them inside your project.
Making HTTP Calls.
We’ll start with a very simple request.
Here we define 5 seconds maximum to fetch the response from the API, if the response is not returned we get a TimeoutException
If we do not want to specify the wait time, and allow it to wait till the response comes. We can easily do that by using
[[scala.concurrent.duration.Duration.Inf Duration.Inf]] for unbounded waiting.
Making HTTPS Requests and Configuring the HttpMethods.
We can also define HTTPS request by defining
But this does not solve…
View original post 135 more words