<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URLSession/data(for:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:So12NSURLSessionC10FoundationE4data3forAC4DataV_So13NSURLResponseCtAC10URLRequestV_tYaKF"
  },
  "title" : "data(for:)"
}
-->

# data(for:)

Convenience method to load data using a URLRequest, creates and resumes a URLSessionDataTask internally.

```
func data(for request: URLRequest) async throws -> (Data, URLResponse)
```

## Parameters

`request`

The URLRequest for which to load data.

## Return Value

Data and response.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)