I’d like to use the autocomplete (API) field by fetching values from another collection in the same Directus database. I believe that in order for us to use the built-in RESTful API that Directus creates we need to pass a header with the authorisation token with every request. The autocomplete field does not have an option for us to add an authorisation header to our requests, so is there a way to do this? Can we pass the authorisation token as part of the URL query string?
Worked it out — posting solution here so others can reference it.
SOLUTION: when making an API request, we can indeed pass an access token in the URL using access_token=XXX in the query string — for example, like this:
We can use this in the ‘URL’ field of the autocomplete input settings to fetch the data from a collection in the database. We can use other query parameters such as fields and filter, just as we normally do when using the API — using {{value}} in the parameters to filter out the responses.
Last of all, in the “Results Path” setting field, enter simply the word data - that is the path - and don’t forget to specify “Text Path” and “Value Path” using the names of the fields you want to use for each.