URLSession "data(for request: URLRequest, delegate:) async throws -> (Data, URLResponse)" function migration?

As an aside you probably don't want to be using URLSession in a Vapor app. URLSession works well for a client with one user but it doesn't integrate with EventLoops, you don't get to take advantage of connection pooling and a host of other issues. You should use AsyncHTTPClient and Vapor provides that via req.client and app.client. It also has functions for decoding Content etc, using the same HTTPHeaders so I recommend just using that.

There's more info on the docs

3 Likes