How can I get back the Headers of a Collection or GET REST API call?

Hey :wave:

I’m using Full-Text Search on a Supabase table. So for this, I’m obliged to use a REST API call as WeWeb’s Supabase plugin doesn’t handle this use-case.

I want to add pagination on top of this. The thing is, Supabase (and PostgREST) send back the current range as response headers (NOT in the actual payload). So I need to store this header’s value to handle my own custom pagination.

So, instead of a collection (where we can’t see response headers, btw, that would be a useful feature), I switched to a REST API call that I trigger on page load. But it seems that I can get back the response headers as it’s a GET request.

Is there any way to get the Header or am I missing something?

Here’s a small video to explain the case:

Thanks a lot for your help :pray:

1 Like

No way this is you man. I was thinking about where you gone after leaving my mustache grow. You can use full text search with the Supabase plugin in WeWeb. It’s just the shitty naming, I also fell for that. This filter will let you use the Full Text Search.

1 Like

Hey man thanks!

I managed to make it work (even if the setup was unclear). But I still don’t have my range Header back from the Response.

I think I can “cheat” by computing the number of ranges from the count and keep count of the current range internally, but that’s over-engineered for such a simple thing…

I’d probably go straight for a Stored Procedure, you can use the FTS also there. And you can construct your response however you need it. For “complex” things like this I just make my own (security definer) stored procedure and call it. It’s supafast. Otherwise, you can use Axios which is in WeWeb and get all the infos you need.

1 Like

same issue here, I need to get the header back from my collection, especially the content-range parameter of my header

Hey! If I understood correctly, you’re trying to extract some values from a WeWeb collection and use them in the DOM, right?

If that’s the case, I can think of two possible approaches:

  1. One way is to iterate over the existing project collections and look up the one you need by using a key or a value from your current instance. This should return the collection itself for you to grab whatever you need.

  2. The other option would be to use one of the functions I shared in my cheatsheet (link below) on how to use collections dynamically. Specifically the one that retrieves the current collection’s config. That should give you access to the queries and values it’s using to request data.

Just keep in mind: if the data is coming in dynamically, it often returns the variable as a string (like the literal {{DYNAMIC_VARIABLE_IDENTIFICATOR_NOT_THE_VALUE}}) instead of the actual value, so you’ll likely need to apply just a bit of data transformation to get what you need.

Here’s the link to the guide. Hope it helps and is what you’re looking for!

- Dynamic Collection Manipulation Guide

Best,
Bruno

I’m trying to get back the header of any api call.
so far, the response just returns the body. I want the header too.

But the solution i went for, was to make a fetch call via the custom javascript action, more flexible, and therefore I got my header as I wanted