My question:
Values become null if I leave them empty in PUT
Hello!
For the most part, let’s say I have a parameter like:
{
"_id": 31,
"username": "userName2",
"email": "[email protected]",
"password": "password",
"gender": "Female",
"register_date": "2022-01-04",
"about": "A very cool user",
"fav_received": 0,
"fav_given": 0,
"profile_picture": "images/pfp3",
"member_type": "Normal",
"reviews_made": 0
}
And I just want to update its username via PUT to something like
{
"username": "New Username"
}
I want a result like:
{
"_id": 31,
"username": "New Username",
"email": "[email protected]",
"password": "password",
"gender": "Female",
"register_date": "2022-01-04",
"about": "A very cool user",
"fav_received": 0,
"fav_given": 0,
"profile_picture": "images/pfp3",
"member_type": "Normal",
"reviews_made": 0
}
With all the other values intact,
But I get:
{
"_id": 31,
"username": "New Username",
"email": null,
"password": null,
"gender": null,
"register_date": null,
"about": null,
"fav_received": null,
"fav_given": null,
"profile_picture": null,
"member_type": null,
"reviews_made": null
}
All the other values I did not update in the previous post request become null. How would I be able to fix this? Thank you in advance!