How to set other server responses for 'Server Connect' action

In the App Structure>Dynamic Events>Server Connect>
there are actions for start, done, error, unauthorised etc etc

What I would like to know is for example if I want to have multiple error notifications eg:

400 - Check your details
415 - Check File Format
404 - Information not found

How would I set this up ?

Hello,
are you asking how to set these responses in the server action, or how to show them on the page?

I want to know for example if it returns:
404 then i want to show a notification that ā€˜Information has not been foundā€™
400 then i want to show a notification that ā€˜Check your informationā€™

I get how to do the standard notification on start, error, unauthorised etc etc
But I want to fine tune it to different error codes.

Well that is my question - are you setting these in the server action yourself, using Response steps, or are you using some API which returns them?
Also how/where would you like to display these messages exactly?

Sorry, I will be setting a response in the Action Steps.

I want the messages to be set up to Notifications in App Structure.

Well then just use on error event to call the notification and bind the Last Error > Response

ok and then put a condition that the last error == 404 or contains 404

No - why would you need that?
Last error will return the last error message returned by your server action. You donā€™t need any condition.

ok but how would the notification know the difference?
Please correct me if I am wrong here but if I add a notification to show when it returns invalid then would it not show the same notification for 400 & 404 ?

The notification will return the text you put in the Set Response step in your server action.

Screenshot_22

2 Likes

Ahha, the penny drops. let me give it try. Cheers @Teodor

There is an example of using the returned status in this thread, in case it helps.

2 Likes

Iā€™m having a problem with the custom response. It seems to me that it was after the Wappler update, as it was working before.
Error:
dmxConnectLib\lib\core\Response.php",ā€œlineā€:238,ā€œmessageā€:ā€œArray to string conversionā€,ā€œtraceā€:"#0

Please check
https://community.wappler.io/t/error-from-response-php/37784/6

Tks!