Question: Create a new API endpoint in the back end that will be responsible for displaying a custom message. Step 1 : Add a back -
Create a new API endpoint in the back end that will be responsible for displaying
a custom message.
Step : Add a backend endpoint
Go to the backend folder.
Edit server.js
Add a new endpoint: appgetapimessage
Define a custom message in the endpoint's response.
Save and start the backend server.
Step : Fetch the message from the front end
Go to the frontend folder.
Open srcAppjs
Import the necessary libraries.
Add a new state: const customMessage setCustomMessage
useState;
Use useEffect to fetch a message from apimessage
Update customMessage with the fetched message.
Display customMessage in your app.
Step : Run servers and check
Run both backend and frontend servers.
Open your app in a web browser.
You should see the original and custom messages displayed.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
