hello guys well I had created a form with few Jews that is similar to the formulae of the update firmware I wonder how can I send data from my front to the server
this is my Hello.vue code :
import axios from “axios”;
export default {
name: “hello”,
data() {
return {
Fuota: {
devEUI: "string",
fuotaDeployment: {
dr: 0,
frequency: 0,
groupType: "CLASS_C",
id: "string",
multicastTimeout: 0,
name: "string",
nextStepAfter: "2020-03-11T10:30:53.463Z",
payload: "string",
redundancy: 0,
state: "string",
unicastTimeout: "string"
}
}
};
},
methods: {
addToAPI() {
let newFuota = {
devEUI: this.Fuota.devEUI,
fuotaDeployment: {
dr: this.Fuota.fuotaDeployment.dr,
frequency: this.Fuota.fuotaDeployment.frequency,
groupType: this.Fuota.fuotaDeployment.groupType,
id: this.Fuota.fuotaDeployment.id,
multicastTimeout: this.Fuota.fuotaDeployment.multicastTimeout,
name: this.Fuota.fuotaDeployment.name,
nextStepAfter: this.Fuota.fuotaDeployment.nextStepAfter,
payload: this.Fuota.fuotaDeployment.payload,
redundancy: this.Fuota.fuotaDeployment.redundancy,
state: this.Fuota.fuotaDeployment.state,
unicastTimeout: this.Fuota.fuotaDeployment.unicastTimeout
}
};
console.log(newFuota);
var headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
};
var options = {
url:
"http://159.8.95.109:8080/api/devices/3135238f59b6267/fuota-deployments",
method: "POST",
headers: headers,
body: newFuota
};
//mongodb database
axios
.post("http://localhost:3000/api/Fuota1Models", newFuota)
.then(response => {
console.log(response);
})
.catch(error => {
console.log(error);
});
}
}
};