In the Vapor framework for server side swift, I would like to respond to a request with info I got from third party API. For example, I receive a get request asking for the temperature of a city, and I want to connect to yahoo whether API to get the temperature then send it back. Do I need to download packages like Alamofire? Or Is there a built in way to do so in Vapor?
How to make requests to connect to third party APIs in Vapor?
2.5k views Asked by naif At
1
There is a built-in HTTP client in Vapor; it is called
Client
.To make a
GET
request to your third party API:You can pass your query parameters in the query string, or using the convenient dictionary method:
Client
also supportsPOST
, or any other HTTP method.