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

**URL:** <https://forums.swift.org/t/urlsession-data-for-request-urlrequest-delegate-async-throws-data-urlresponse-function-migration/58813>\
**Category:** Using Swift\
**Tags:** foundation, concurrency, urlsession, beta\
**Created:** [July 10, 2022, 5:54am UTC](https://forums.swift.org/t/urlsession-data-for-request-urlrequest-delegate-async-throws-data-urlresponse-function-migration/58813 "2022-07-10T05:54:37Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![0xTim](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/0xtim/32/27968_2.png) [@0xTim](https://forums.swift.org/u/0xTim)\
**Post date:** [July 10, 2022, 9:08am UTC](https://forums.swift.org/t/urlsession-data-for-request-urlrequest-delegate-async-throws-data-urlresponse-function-migration/58813/3 "2022-07-10T09:08:09Z")

</div>

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 `EventLoop`s, 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](https://docs.vapor.codes/basics/client/)

---

_[View the full topic](https://forums.swift.org/t/urlsession-data-for-request-urlrequest-delegate-async-throws-data-urlresponse-function-migration/58813)._
