# How to Fetch Dropdown Options from an API

{% hint style="warning" %}
**Note: This page only applies to the Old Rendering Engine** - for the New Rendering engine ask a Savvy Expert for help
{% endhint %}

{% hint style="info" %}
You can insert manually the Dropdown options as if they were buttons from an option selector, but in some cases where options are too many, and there's an API that does this, you can fetch the options and filter them with your input.&#x20;

There are two levels to this. You can fetch all the options (and it will filter them in the frontend as you type) OR if there are hundreds of results then you can do a live search as you type with {{$query}}
{% endhint %}

### Step 1: Get the Dropdown Component Ready

* Create the dropdown component
* Check the "Fetch Options from an API" box that you'll find in the Advanced dropdown of the Options tab

![](https://1421794749-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaGcfSakhqdHaWyb0T_%2Fuploads%2Fou8lL2DdxDAjxb9D1UrC%2Fimage%20\(59\).png?alt=media\&token=df5637a5-406d-44ea-8a31-709a1d8ee311)

* "Allow typing" and "Clearable" should also be checked!

![](https://1421794749-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaGcfSakhqdHaWyb0T_%2Fuploads%2F893XMk9m1aaW4wRIAIAu%2Fimage%20\(63\).png?alt=media\&token=435889ae-b49d-4989-b3c8-e4a27c6be0cd)

### Step 2: Set your URI

* Paste the URL you want to fetch from in the "Fetch URI" input box that's will appear when checking the "Fetch Options from an API" box
* In the before-mentioned case where there are hundreds of results, you can do a live search by passing a query parameter. You'll have to add `{{$query}}` where the param should go. That will automatically insert whatever you type in the dropdown component in the fetch URI

![](https://1421794749-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaGcfSakhqdHaWyb0T_%2Fuploads%2FukKofqYgGhW7IcXphCU9%2Fimage%20\(60\).png?alt=media\&token=1ea4eea9-3222-483d-a2d9-f58b6f5a6982)

### Step 3: Add your Fetch Headers and Transformers

* For the Headers, you'll need an object like this one:

![](https://1421794749-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaGcfSakhqdHaWyb0T_%2Fuploads%2FpKADcB8gr50xS7VhFsAz%2Fimage%20\(61\).png?alt=media\&token=8a4983d1-ab62-454c-a085-763c7f93624a)

* And your Transformers need to be inside a function called "transformer" that gets passed `data` (the response from the fetch) as an argument and returns the data transformed.

![](https://1421794749-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MaGcfSakhqdHaWyb0T_%2Fuploads%2F3s0zNtGDEHFBIntLXXlB%2Fimage%20\(62\).png?alt=media\&token=b682cf0e-e014-441c-bada-ce0bac16fd1d)
