Autodesk OA Coding Interview: Login Form Exercise

14 Views
No Comments

Login Form Exercise

This is an incomplete login form.

Do not add any additional HTML elements.

The login() service works as follows:

  • Accepts an email and password, returns a JSON response containing either a token if successful or an error if there is an issue.

Examples:

  • Valid email address (any password is valid): emma.wong@reqres.in, returns {"token":"QpwL5tke4Pnpja7X3"}
  • Invalid email address, returns {"error":"user not found"}

Tasks:

  • The login button should trigger the login service.
  • Show an error message from the login service.
  • Clear the error message every time the user re-attempts login.
  • Show an alert box (native Javascript alert) on successful login.

This problem focuses on frontend form behavior and async login handling. You need to wire the existing login button to the provided <code>login()</code> service, display the returned error message when the request fails, clear previous errors on every new attempt, and show a native alert when login succeeds. The key skills are event handling, simple state management, and conditional UI feedback based on API responses.

END
 0