Open dhanashri-dotcom opened 1 month ago
/api/update-user/:id
PUT
URL Parameters:
id
(string): The unique ID of the user whose information needs to be updated.Request Body: The request body contains the updated data for the user. This should be a JSON object with the fields that need to be modified. Example:
{
"id": "d168",
"age": "3333",
"gender": "female",
"work_experience": 0,
"canada_workex": "10",
"dep_num": 0,
"canada_born": "false",
"citizen_status": "",
"level_of_schooling": "",
"fluent_english": "true",
"reading_english_scale": 0,
"speaking_english_scale": 0,
"writing_english_scale": 0,
"numeracy_scale": 0,
"computer_scale": 0,
"transportation_bool": "false",
"caregiver_bool": "false",
"housing": "",
"income_source": "",
"felony_bool": "false",
"attending_school": "false",
"currently_employed": "false",
"substance_use": "false",
"time_unemployed": 0,
"need_mental_health_support_bool": "false"
}
Success Response:
200 OK
{
"message": "User updated successfully",
"userId": "d168",
"updatedData": {
"id": "d168",
"age": "33",
"gender": "male",
"work_experience": 0,
"canada_workex": "10",
"dep_num": 0,
"canada_born": "false",
"citizen_status": "",
"level_of_schooling": "",
"fluent_english": "true",
"reading_english_scale": 0,
"speaking_english_scale": 0,
"writing_english_scale": 0,
"numeracy_scale": 0,
"computer_scale": 0,
"transportation_bool": "false",
"caregiver_bool": "false",
"housing": "",
"income_source": "",
"felony_bool": "false",
"attending_school": "false",
"currently_employed": "false",
"substance_use": "false",
"time_unemployed": 0,
"need_mental_health_support_bool": "false"
}
}
Error Responses:
{
"message": "User not found"
}
{
"message": "Error reading database"
}
or
{
"message": "Error updating database"
}
db.json
file using fs.readFile
. This JSON file contains all the user form submissions.id
in the form-submissions
array within the database.req.body
) with the existing user data.db.json
file using fs.writeFile
.404 Not Found
response.db.json
file, the API returns a 500 Internal Server Error
response.
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: