Custom URL query parameters

Hello Frontity! Im having a bit of a love/hate relationship with you atm. Some things are super easy and work well, others not so much.

Im trying to do something I thought would be incredibly easy, add a custom URL query parameter to my actions.source.fetch request. Its proving to be extremely frustrating.

I have a custom rest query hook (https://developer.wordpress.org/reference/hooks/rest_this-post_type_query/) set up on wordpress that I would like to use to filter a custom post type endpoint’s response. Every time I try to do this using actions.source.fetch the custom URL parameters get stripped.

Please help!

Hi @jack.templeman.user1

Welcome to the Frontity community. Can you provide a code sample, or better still a link to a repo, so that we can see what you’re trying to do. Thanks.

Hello @mburridge,

Thanks for the welcome and apologies for not getting back to you sooner. Deadlines, etc.

What I am trying to achieve is retrieve a filtered list of people that belong to a particular business from my Wordpress API. I have the filter set up on Wordpress and its working as intended. However, when I go to request these filtered results like the below and review the request my Wordpress API receives, it appears Frontity strips the ‘businesses’ URL query.

actions.source.fetch('/person/?businesses[]=ID_OF_BUSINESS');

In the end, I used Frontity’s ‘fetch’ function in useEffect. This works, but ideally I wanted that data already available on the server ready for SSR.

Kind regards,

Jack

Hi @jack.templeman.user1

In that case use a beforeSSR action. Documentation is here, and here is an example of it’s usage.

Hope this helps.

Hello @mburridge,

Completely understand the above. This is where I was trying to grab data before.

However, the issue is with Frontity stripping the custom url parameters.

For example:

beforeSSR: ({ state, libraries, actions }) => {
    actions.source.fetch('/person/?businesses[]=1');
}

Produces the following request to the API:

/wp-json/wp/v2/person?_embed=true&page=1

When I would expect:

/wp-json/wp/v2/person?businesses[]=1&_embed=true&page=1

Thank you for looking into this!

Any update on this? I’m struggling exactly with the same issue.