I have a question that I just can't seem to figure out:
So, I have this input form:
<form @submit.prevent="customSubmit">
<label>Name</label>
<input type="text" v-model="newUser.name" id="name" placeholder="Your Name">
<label>E-mail:</label>
<input type="email" v-model="newUser.email" id="email" placeholder="Your Email-Address">
<label>Mobile Number</label>
<input type="number" v-model="newUser.number" id="number" placeholder="Your mobile number" @keyup.enter="customSubmit">
</form>
<button type="button" class=buttonSignup @click="customSubmit">Submit</button>
The data is processed and sent to a nodeJS server using the following function:
customSubmit(){
//Check if all fields are filled
if(document.getElementById('name').value === ''){return}
if(document.getElementById('email').value === ''){return}
if(document.getElementById('number').value === ''){return}
//POST to API
const user = {
method: "POST",
headers: { "Content-Type": "application/json"},
body: JSON.stringify({newUser: this.newUser})
};
fetch("http://localhost:3080/api/user", user)
.then(response => response.json())
.then(data => console.log(data));
this.pushFunction(); //GET request to view the data
this.clearForm();
}
Now, in order to send a DELETE request as well, I need to assign unique IDs to each entry within the customSubmit() function.
Can someone guide me on how to do this?
Thank you!
PS: Please disregard the German comments in the code snippets.