# Redirect based on collection error

**URL:** <https://community.weweb.io/t/redirect-based-on-collection-error/574>\
**Category:** Ask us anything\
**Created:** [May 23, 2022, 1:17am UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574 "2022-05-23T01:17:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevinwasie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kevinwasie/32/402_2.png) [@kevinwasie](https://community.weweb.io/u/kevinwasie)\
**Post date:** [May 23, 2022, 1:17am UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/1 "2022-05-23T01:17:35Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Edward](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/edward/32/249_2.png) [@Edward](https://community.weweb.io/u/Edward)\
**Post date:** [May 27, 2022, 9:36pm UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/2 "2022-05-27T21:36:06Z")

</div>

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.

 ![screenshot-editor.weweb.io-2022.05.27-22_31_59](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/1X/6827d811083de6a5c400b719e0f7d5220b5605a6.png)

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

---

<div class="post-metadata">

**Author:** ![kevinwasie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kevinwasie/32/402_2.png) [@kevinwasie](https://community.weweb.io/u/kevinwasie)\
**Post date:** [May 27, 2022, 11:09pm UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/3 "2022-05-27T23:09:18Z")

</div>

@Edward you are on fire!

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [May 30, 2022, 1:15pm UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/4 "2022-05-30T13:15:36Z")

</div>

Nice one @Edward 🙌

---

<div class="post-metadata">

**Author:** ![kevinwasie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kevinwasie/32/402_2.png) [@kevinwasie](https://community.weweb.io/u/kevinwasie)\
**Post date:** [July 14, 2022, 9:24pm UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/5 "2022-07-14T21:24:15Z")

</div>

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

Any thoughts on how to make that work

 ![Screen Shot 2022-07-14 at 5.22.49 PM](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/1X/6a2ed2d951f2fd18b76938aa5b9786f1fd9685ff.jpeg)  
?

---

<div class="post-metadata">

**Author:** ![kevinwasie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kevinwasie/32/402_2.png) [@kevinwasie](https://community.weweb.io/u/kevinwasie)\
**Post date:** [July 14, 2022, 9:39pm UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/6 "2022-07-14T21:39:31Z")

</div>

@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](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/1X/df220a81c9191d97e6b0322d1d35e9df2d104a0f.png)

---

<div class="post-metadata">

**Author:** ![Edward](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/edward/32/249_2.png) [@Edward](https://community.weweb.io/u/Edward)\
**Post date:** [July 14, 2022, 9:42pm UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/7 "2022-07-14T21:42:11Z")

</div>

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

 ![Screenshot_20220714-225750](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/1X/37a73b99e56b1b7c1e7e16da927574a3102271a7.jpeg)  
see if there is anything relates to the error and use that variable with dot notation

---

<div class="post-metadata">

**Author:** ![kevinwasie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/kevinwasie/32/402_2.png) [@kevinwasie](https://community.weweb.io/u/kevinwasie)\
**Post date:** [July 14, 2022, 10:10pm UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/8 "2022-07-14T22:10:52Z")

</div>

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](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/1X/59b90157fa7ec3caa3faa882104a00ecf83ea149.png)

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [July 18, 2022, 8:15pm UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/9 "2022-07-18T20:15:03Z")

</div>

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:

 ![CleanShot 2022-07-18 at 22.13.08@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/1X/90d09ee58417f1cd5da68691ae987e7fa05c5489.jpeg)

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?

---

<div class="post-metadata">

**Author:** ![Edward](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/edward/32/249_2.png) [@Edward](https://community.weweb.io/u/Edward)\
**Post date:** [July 18, 2022, 9:17pm UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/10 "2022-07-18T21:17:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Joyce](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/joyce/32/13232_2.png) [@Joyce](https://community.weweb.io/u/Joyce)\
**Post date:** [July 19, 2022, 4:36pm UTC](https://community.weweb.io/t/redirect-based-on-collection-error/574/11 "2022-07-19T16:36:02Z")

</div>

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.
