Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

orest's avatar
Level 13

handle response message in front or back end ?

When i make a request from the front end to the back end ( post, get etc) with axios for example

I can use then and catch to handle either a successful or a failed request and flash a message in the front end to give feedback to the user.

For example.

axios.get('/apples')
.then((response) => flash("You got the apples"))
.catch((error) => flash("You didn't get the apples"));

Or i can write the messages in the back end and then use them to flash the messages in the front end.

For example

axios.get('/apples')
.then((response) => flash(response.message)
.catch((error) => flash(error.message));

My question is whether there is a reason to prefer either one, or it does not matter ?

0 likes
1 reply

Please or to participate in this conversation.