Use async await for createTimetrackAccount
This commit is contained in:
parent
5748cc8410
commit
ee1f4c5222
@ -35,36 +35,32 @@
|
|||||||
</v-container>
|
</v-container>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import {BASE_URI} from "../globals";
|
import {BASE_URI} from "../globals"
|
||||||
import axios from "axios"
|
import axios from "axios"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "CreateTimeTrackAccount",
|
name: "CreateTimeTrackAccount",
|
||||||
data: () => ({
|
data() {
|
||||||
user: sessionStorage.getItem("timeTrackAccountListUserId"),
|
return {
|
||||||
accountData: {name: "", revenue: "", description: ""}
|
user: sessionStorage.getItem("timeTrackAccountListUserId"),
|
||||||
}),
|
accountData: {name: "", revenue: "", description: ""}
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addAccount() {
|
async addAccount() {
|
||||||
if (Object.values(this.accountData).every(data => data)) {
|
if (Object.values(this.accountData).every(data => data)) {
|
||||||
let postData = {
|
let postData = {
|
||||||
user: this.user,
|
user: this.user,
|
||||||
...this.accountData
|
...this.accountData
|
||||||
}
|
}
|
||||||
let config = {
|
try {
|
||||||
headers: {
|
await axios.post(BASE_URI + "/accounts", postData)
|
||||||
'Authorization': sessionStorage.getItem("jwt")
|
await this.$router.push("/timetrackaccounts")
|
||||||
}
|
} catch (err) {
|
||||||
|
console.log("Error " + err)
|
||||||
}
|
}
|
||||||
axios.post(BASE_URI + "/accounts", postData, config)
|
|
||||||
.then(() => {
|
|
||||||
this.$router.push("/timetrackaccounts")
|
|
||||||
})
|
|
||||||
.catch(err => {
|
|
||||||
console.log("Error " + err)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user