POST action error 401

On several occassions we are being returned a 401 Unautorized on a POST endpoint and we are trying to use that 401 error code to execute error logic - however we are unable to “capture” that error code and handle the error in subsequent logic. What are missing here? Any pointers? Thanks!

You might want to look at what the error looks like actually. Try console logging it and then access the property that contains the status code based on that.

1 Like

nah
the target we want
is
wanna weweb return the response of other action (like POST, DELETE,…)
like the FETCH action
you can see Ben’s capture

  • just have “on Collection Fetch Error”
  • in tab network, we met a 401 error from DELETE action but weweb doesnt return it
  • we wanna take this response to execute the 401 action like the 401 error on fetch action
1 Like

Hello :wave:

Interesting! I just tried with a login form that has incorrect login information.

In the response from Xano, I get the status code. Any chance your backend returns that info?

In order to access the Current error object, I had to:

  • close the workflow
  • go to preview mode
  • trigger the faulty behavior (in my case submit a form with incorrect credentials)
  • then go back to the workflow

Does that help?

Thanks Joyce,
But we wanna it will give the global error for each 401 error
like action FETCH collection error, this is global response: whenever a collection fetched error, it will give us the response, so we can handle it (example 401 => logout and goto login page), we can do it for every collection
so in here, we wanna the 401 error will given to use every other api called to not to handle one by one

Hi @Joyce is the description of the issue sufficiently clear? Let us know how we can be more descriptive (if need be). Thanks! :pray:

Actually a short video walking us through what you’re attempting would help a lot. Thanks for asking @ben.

For example, from the description, I don’t understand if the workflow is on app load, on page load of the home page, or somewhere else. Every time a collection is fetched I guess?

Also, from what I understand, you want one workflow that would handle any type of error that was returned by the API but I don’t know if all the collections are with the same backend (which would be helpful because the error message would be in the same place and formatted the same way).

Hi @ben and @eric ,

Indeed it looks like On Collection Fetch Error does not return the full error object. I have a question though, can’t you see the logs on the Xano side? The 401s? So you could check the payload.

Thanks @Joyce @flo


Actually we want is the response of others action error will show for us.
I will describe again like this: I have collection A, B, C, … and whenever I fetch them, if error, I will receive their error response from “On Collection Fetch Error” right?
And, what we want is that where we can get the “On Delete Error”, “On Post Error”, … etc for all others action
Like the capture, I make a DELETE action and it error, receive 401 response, and I want the global response for all case like this, not to set error action for each action.
That is our thought.