Redirect based on collection error

If a collection that is used in the page returns an error code, ie Unauthorized, I’d like to redirect to a standard error page.

How can I do this?

1 Like

I would do something like: On page load > run workflow:

your collection returns error:null if the request was fine. It returns error:object if request was not fine. From here, you can do a pre condition filter for the workflow:

If error != null (doesn’t equal") return true otherwise false

If true is returned, the workflow continues

next step is to redirect the user to error page.

you can use the above method in any workflow, not only on page load.

1 Like

@Edward you are on fire!

1 Like

Nice one @Edward :raised_hands:

@Edward I cannot get the collection to return the .error value.

Any thoughts on how to make that work


?

@joyce Any thoughts on how to go about this now… getting the error from a collection?

That property is now not in the collection object:

Screen Shot 2022-07-14 at 5.38.48 PM

Can you check under response? Im on mobile now, but I would check the object under response to


see if there is anything relates to the error and use that variable with dot notation

Hmm. Yes, that would work but it appears that you cannot access that in a collection when there is an error. There must be some wrapper on the collection to expose properties in WeWeb.

doing collection[“asdf”].response yields undefined.

Screen Shot 2022-07-14 at 6.09.05 PM

Mmm I’m not sure… the response is in WeWeb so there must be a way to access it directly from the Collection. Let me ask the tech team and get back to you!

In the meantime, the workaround I can think of is to trigger the API call for the Collection in a Workflow:

I’ve added a “test jk” page and “test jk” variable in your project to show you.

In the variable, I would bind the error message from the result of action 1, then display that variable in a modal.

Does that help?

After taking a second look, it seems like you were using Xano plugin, where as I was using standard API collection with Xano, so Im thinking the plugin does not return error in json the same way like rest api collection to Xano does. As you can see on my original screenshot, the reason I was able to define .error after collection name, because it’s there as an object, and I think this is whats missing from the plugin’s response

Just heard back from the tech team. It is indeed an improvement we need to make on our side so you can access the error message in the data tab or through a refetch collection in a workflow.

1 Like