Fernanda
Fernanda

Reputation: 37

Throw alert message Node.js

So I have this payment service where I want to do so: If the response from the payment API is "CA" I want to display an alert message to the user. Can I do that on the back-end or can I accomplish that only with the front-end? I really wanted to do with both.

 try {
     
         if (transaction.status === 'CO') {
               await EmailPayments.confirmedSupport(transaction);
                        await
                        });
                    } else if (transaction.status === 'CA') {
                        await EmailPayments.pendingSupport(transaction);
                    }
                } catch (error: Error | unknown | any) {
                    new Logger().error(error);
                }

Upvotes: 0

Views: 289

Answers (1)

Erick Villatoro
Erick Villatoro

Reputation: 170

No, you can not display an alert in the frontend from the backend. Your approach to this should be: Send a request from the frontend -> Response from the backend -> Pop up an alert in the frontend whenever the response had been successful. For that you can use fetch or axios.

Upvotes: 1

Related Questions