async function searchTypesenseAuthenticated()

in fulltext-search-firestore/public/index.js [135:163]


async function searchTypesenseAuthenticated(query) {
  // [START search_typesense_authenticated]
  // Get a scoped TypeSense API key from our Callable Function
  const getScopedApiKey = firebase.functions().httpsCallable('getScopedApiKey');
  const scopedApiKeyResponse = await getScopedApiKey();
  const apiKey = scopedApiKeyResponse.data.key;

  // Create a Typesense Client
  const client = new Typesense.Client({
    'nodes': [{
      'host': 'xxx.a1.typesense.net', // where xxx is the ClusterID of your Typesense Cloud cluster
      'port': '443',
      'protocol': 'https'
    }],
    'apiKey': apiKey,
    'connectionTimeoutSeconds': 2
  });

  // Search for notes with matching text
  const searchParameters = {
    'q': query,
    'query_by': 'text'
  };
  const searchResults = await client.collections('notes')
    .documents()
    .search(searchParameters);
  // ...
  // [END search_typesense_authenticated]
}