---
title: "fetchData(forBundleIdentifier:itemIdentifier:contentType:completionHandler:)"
framework: corespotlight
role: symbol
role_heading: Instance Method
path: "corespotlight/cssearchableindex/fetchdata(forbundleidentifier:itemidentifier:contenttype:completionhandler:)"
---

# fetchData(forBundleIdentifier:itemIdentifier:contentType:completionHandler:)

Fetches data from an external provider.

## Declaration

```swift
func fetchData(forBundleIdentifier bundleIdentifier: String, itemIdentifier: String, contentType: UTType, completionHandler: @escaping @Sendable (Data?, (any Error)?) -> Void)
```

```swift
func fetchData(forBundleIdentifier bundleIdentifier: String, itemIdentifier: String, contentType: UTType) async throws -> Data
```

## Parameters

- `bundleIdentifier`: The bundle identifier of the app to search.
- `itemIdentifier`: The app-specific identifier of the item you want.
- `contentType`: The type of data to fetch.
- `completionHandler`: The block to execute with the results. The block has no return value and takes the following parameters:

## Discussion

Discussion Clients with the appropriate entitlements can use this method to fetch data from an external app such as Mail. important: You can call this method from synchronous code using a completion handler, as shown on this page, or you can call it as an asynchronous method that has the following declaration: func fetchData(forBundleIdentifier bundleIdentifier: String, itemIdentifier: String, contentType: UTType) async throws -> Data For information about concurrency and asynchronous code in Swift, see Calling Objective-C APIs Asynchronously.
