I have a VueJS application that calls a patch method to update a user's profile. For example, I am attempting to update the field cities.
I created a serializer and views.py using Postman during development. I used Postman to call the patch method for updating the user profile, as shown in the command below. Patch always worked when called from the Postman API.
"cities": [
"SANTA CLARA",
"MILPITAS"
]
After completing development, I tried to integrate with my VueJS app. I am passing cities from a text box, as shown in the following code:
<div class="form-group col-md-12">
<label for="">Prefered Cities to work</label>
<input
type="text"
class="form-control"
ref="cities_input"
id="cities"
v-model="userDetails.cities"
/>
In the form save action, the code uses the following function:
formData.set("cities", this.$refs.cities_input.value);
If only one city is provided in the text box, the values are updated in the database successfully. However, if more than one city is provided in the text box (e.g., "SANTA CLARA","MILPITAS"), or without quotes like SANTA CLARA,MILPITAS, the values are not updated in the database. Any help would be highly appreciated.
I also attempted hardcoding in the save action as follows, but it did not result in successful saving:
formData.set("cities", [ "SANTA CLARA","MILPITAS"]);