---
title: SearchDelegate
framework: mapkitjs
role: symbol
role_heading: Type
path: mapkitjs/searchdelegate
---

# SearchDelegate

An object or callback function the framework calls when performing a search or an autocomplete request.

## Declaration

```data
type SearchDelegate<
    T extends SearchResponse | SearchAutocompleteResponse =
        | SearchResponse
        | SearchAutocompleteResponse,
> =
    | {
          searchDidError: (error: Error) => void;
          searchDidComplete: (result: SearchResponse) => void;
          autocompleteDidError: (error: Error) => void;
          autocompleteDidComplete: (result: SearchAutocompleteResponse) => void;
      }
    | ((error: Error | null, result: T | null) => void);
```

## Discussion

Discussion You can also pass an object to the search(query, options) and autocomplete(query, options) methods instead of a search delegate callback function. A delegate object can include the following methods: searchDidComplete. Upon successful completion of a search request, this method returns a data object that’s the same as the one that passes to the search callback function. searchDidError. The system calls this when the search request fails. autocompleteDidComplete. When an autocomplete request successfully completes, this method returns a data array that’s the same as the one that passes to the autocomplete callback function. autocompleteDidError. The system invokes this when an autocomplete request fails.

## See Also

### Performing a search

- [search(query, options)](mapkitjs/search/search.md)
- [SearchOptions](mapkitjs/searchoptions.md)
- [SearchResponse](mapkitjs/searchresponse.md)
