How to Access Server Connect "Unauthorized" Error Message When lastError.Response is [Object, Object]

I have a server connect which I expect sometimes to return unauthorized. Here is how it looks when it does this:

How can I access the text of the field “message” shown here within Wappler?

I’ve tried these options:

manage_activity_payment_intent.data.error.message (is empty string)
lastError.response (is" object object")
lastError.message (just says “Unauthorized”)
lastError.status (is" 401")

Thanks!
Antony.

error.message

is what is shown in your screenshot, no?

that should be appended to whatever the server connect name is, then data.

But it looks like you tried that.

So I guess, I’ve got nothing. :slight_smile: Sorry, gotta run.

1 Like

Print the object in console and figure out the path there.
dmx.app.data.sc1...

1 Like

Thanks for the idea about how to find the answer @sid...

So the string you are looking for will be somewhere below the sc_query.lastError.response part of the data...

Here is what I needed in my case:

manage_activity_payment_intent.lastError.response.error.message
1 Like

This is good.
So usually, the error is in the lastError.response. But, in case the error itself is in JSON, it gets converted to this format.
This is practially impossible for Wappler to predict. From the looks of it, you are getting this error from some thrid-party API. So its on you to configure this correctly.

When talking about status codes, like 401,403 etc… the response is usually plain text, and not a JSON. Hence, Wappler has put in simple handling to show the plain text inside lastError.response.
So, in this specific case, you need to handle the different response style.

2 Likes

That makes sense @sid!
Thanks for your bigger perspective on it… :slight_smile: