'Render based on server's response

I am a new SPA developer in React, and I'm building a full-stack web application, [back-end and front-end], while planning, I stopped at a point that I couldn't find a convenient method for. On the Login page, after the user enters his username and password, and hits submit, the form will send a POST request to the server, the server will verify the information provided, if the username and password were true, the server will ask the database to see if the user has activated the two steps verification, in case the user has activated it, the server will send a verification email to the user...

This is well-known, but the point is, how the server is going to tell the client (the React web app) that "hey react, you should render a box of "enter the code sent to your email" rather than rendering the user profile page because this user has two-steps verification enabled.

What is the convenient and the most logical way of writing this response from the server-side? I was thinking of the following response:

// this is the response from the server after submitting the form (sending an AJAX POST request) HTTP code #200 code
      response:{
         UI: {
           showEmailVerificationBox: true,
         }
      }

Is there a standardization for these kinds of responses? where the server wants to tell the client to do something in its UI?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source