Skip to content

Instantly share code, notes, and snippets.

@nilmadhab
Last active September 5, 2021 14:21
<script>
var axios = require('axios')
import swal from 'sweetalert';
export default {
data(){
return {
categoryName : null,
description : null,
imageURL : null,
}
},
methods : {
async addCategory() {
const newCategory = {
categoryName : this.categoryName,
description : this.description,
imageUrl : this.imageURL,
};
const baseURL = "https://limitless-lake-55070.herokuapp.com/";
await axios({
method: 'post',
url: baseURL+"category/create",
data : JSON.stringify(newCategory),
headers: {
'Content-Type': 'application/json'
}
})
.then(() => {
swal({
text: "Category Added Successfully!",
icon: "success",
closeOnClickOutside: false,
});
})
.catch(err => console.log(err));
}
},
mounted(){
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment