Last active
September 5, 2021 14:21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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