Hi all - I'm trying to write a firebase cloud func...
# community-help
s
Hi all - I'm trying to write a firebase cloud function to query a typesense collection. When I was just using the typesense client in typescript directly in my UI, it worked perfectly. But now I'm struggling to make it work as part of the cloud function. I'm able to CURL to see my collection is there, but when I try for example
Copy code
curl -X GET "<https://iuw0dy6lexcj32stp-1.a1.typesense.net:443/collections/userTags/documents>" \
-H "X-TYPESENSE-API-KEY: <my admin key>"
I get { "message": "Not Found"}%
j
That’s not a valid endpoint though. You need to specify a document ID at the end of the get
Or if you’re looking to export all documents add /export at the end of the URL
s
Ahhh - /export absolutely works.
So here's a code sample of what I'm trying to do in my cloud function - I think maybe I have the endpoint syntax wrong.
Copy code
const response = await <http://axios.post|axios.post>(
      `${typesenseProtocol}://${typesenseHost}:${typesensePort}/collections/userTags/documents/search`,
      {
        q: searchText.toLowerCase(), // empty string allowed
        query_by: "tag,category",
        filter_by: `category:${category}`,
        prefix: true,
        infix: "fallback",
        limit: 10,
      },
      {
        headers: {
          "X-TYPESENSE-API-KEY": typesenseApiKey, // Use the secret API key
        },
      },
    );
I think I'm all set. It was format and verb options. Searches are GETs not POSTs
👍 1