dhanashri-dotcom / CommonAssessmentToolUI

0 stars 0 forks source link

Backend: API to update client information #5

Open dhanashri-dotcom opened 1 week ago

dhanashri-dotcom commented 1 week ago

Task: Identify an API that allows updating client profiles. Create placeholder API calls for frontend development if the backend APIs don’t exist yet. Description: Inform the backend team about the api. Add temporary placeholder functions to simulate API interactions that updates client information in the database when changes are made via the frontend. Acceptance Criteria:

xq443 commented 4 days ago

Update API Design

API Endpoint: Update User Info

Request

Response

Workflow

  1. Retrieve User Data: The API reads the user data from the db.json file using fs.readFile. This JSON file contains all the user form submissions.
  2. Locate User: The API searches for the user by their id in the form-submissions array within the database.
  3. Update Data:
    • If the user is found, the API merges the new data provided in the request body (req.body) with the existing user data.
    • The user data is updated in memory.
  4. Write to Database:
    • The API writes the updated data back to the db.json file using fs.writeFile.
  5. Return Response: The API sends back a response indicating the success or failure of the update operation.

Error Handling