AC2 - Using URL param and server connect results in a double API call (one cancelled, and one successful)

Wappler Version : 6.4.1
Operating System : Mac
Server Model: NodeJS
Database Type: MYSQL
Hosting Type: Docker

Expected behavior

I have a Server Connect that uses the param from the URL to load data. This SC auto-loads.
I expect (as per AC1) that this will load once without errors.

Actual behavior

In the screenshow below, you’ll see that my app tries to call the API twice, the first time without the param and the second time with cancelling the first.

Screenshot 2024-04-07 at 4.09.15 pm

For the purpose of this report I created a blank content page with nothing but the URL param and the server connect so as to ensure nothing else on the page was causing the issue. (user and load_notifications are from the layout page).

I can solve this by using a page flow with the url param as the condition - but if we have to use flows for this, then the auto load function of a server connect seems redundant.

Bump on this one team.

If it’s of any help, and perhaps i’m doing something wrong in the way I have queries setup but when I try to select the query manager from the Data Bindings panel it just hangs with the loader:

Screenshot 2024-05-01 at 1.49.24 pm

I have the Query Manager on the layout page.

Noting I’ve tried to have the Query Manager only on the content pages, but it never works, even when just trying to output it to a content page with dynamic data binding.

Is the serverconnect component located on the content page or in the layout page?

@patrick, I think he mentioned in the content page…

1 Like

Correct, thanks @famousmag!

ok this is VERY random… just a question…

Do you use datetime on your page? eg

<dmx-datetime id="var1" utc="true"></dmx-datetime>

and if you do… try setting the interval to minutes or even hours…

<dmx-datetime id="var1" utc="true" interval="minutes"></dmx-datetime>

and then try again…

The serverconnect does a debounce to prevent double calls, when it still does the double call it means that the time between the initial load and the param change took too long. Normally the params data get updated directly after the content page is rendered without any delay.

There are several ways to create a dynamic url for serverconnect using dmx-param: attribute, the dmx-bind:params attribute or a dynamic url dmx-bind:url attribute. Can you post the serverconnect html tag you use.

You can probably achieve the same with the serverconnect by using the dynamic url like dmx-bind:url="query.param ? '/api/single_view?jobuuid=' + query.param" : null, the serverconnect will not load until it has a valid url.

Hey @patrick thank you for the detailed reply.

Here is the tag in question for this page, but noting it happens on a number of pages with different SC’s. But all using the query.jobuuid param.

<dmx-serverconnect id="job" url="/api/employer_user/jobs/manage/single_view" dmx-param:jobuuid="query.jobuuid" dmx-param:period_days="7" dmx-on:success="applicants.load({})"></dmx-serverconnect>

I’ve not used dmx-bind previously, so can you assist in where I would place this? Would I replace url="" with dmx-bind:url="" ?

I tried the ternary here:

<dmx-serverconnect id="job" dmx-bind:url="query.jobuuid ? /api/employer_user/jobs/manage/single_view : null" dmx-param:jobuuid="query.jobuuid" dmx-param:period_days="7" dmx-on:success="applicants.load({})"></dmx-serverconnect>

But resulted in the same double call issue.

What could be causing the issue with the param taking too long, what can I look into here to optimize the work i’m doing?

Do you think the Quary Manager ‘hanging’ on the layout page when I try to select it in the Binding Modal is a potential issue here?

I don’t know where the double call comes from, normally you should not get it. The first call is directly aborted, so none or almost nothing is downloaded and users should even notice it. Also strange that the ternary code didn’t work for you.

Try it with the following code:

<dmx-serverconnect
  id="job"
  url="/api/employer_user/jobs/manage/single_view"
  dmx-bind:params="{ jobuuid: query.jobuuid, period_days: 7 }"
  dmx-on:success="applicants.load({})"
></dmx-serverconnect>

Hey @patrick - tried your update here, and it didn’t work unfortunately.

There are parts of our app that we expect to have a large volume of hits, and so I really want to eradicate things like this from it.

If you like - I can share a link privately with login credentials so you can see what’s going on?