0👍
async addOrder () {
if(this.name.length > 0 && this.address.length > 4 && this.city.length > 3) {
await PostsService.addOrder(
this.postData = {
order: this.cart,
name: this.name,
address: this.address,
city: this.city,
zip: this.zip,
country: this.countries,
summary: this.summary,
status: this.status,
randomNum: this.getRandomNum()
})
setTimeout(() => {
this.$router.push({name: 'EachOrder', params: { id: this._id} })
}, 3000);
} else {
alert('Fill the form')
}
},
getRandomNum() {
return this.randomNum = Math.random() * 30
},
async getId() {
const response = await PostsService.getOrder()
const mapdata = response.data.map(item => {
if (item.randomNum === this.randomNum) {
this._id = item._id
}
console.log(this._id)
})
}
But maybe someone know how to make it easier cuz it’s a lot of code
Source:stackexchange.com