Commit e6ee12b8 authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

remove fetch

parent 81fc4c62
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
type="text" type="text"
class="form-control mb-2" class="form-control mb-2"
placeholder="Description" placeholder="Description"
v-model="sUserID" v-model="sUserId"
size="sm" size="sm"
disabled disabled
/> />
...@@ -279,7 +279,7 @@ export default { ...@@ -279,7 +279,7 @@ export default {
}, },
{ text: "Category ID", value: "category_id" }, { text: "Category ID", value: "category_id" },
{ text: "content", value: "content", sortable: false }, { text: "content", value: "content", sortable: false },
{ text: "user_id", value: "user_id" }, { text: "author", value: "user_id" },
{ text: "status", value: "status" }, { text: "status", value: "status" },
{ text: "Actions", value: "actions", sortable: false }, { text: "Actions", value: "actions", sortable: false },
], ],
...@@ -460,21 +460,20 @@ export default { ...@@ -460,21 +460,20 @@ export default {
async showPost(item) { async showPost(item) {
const ID = item.id const ID = item.id
try { try {
const resp = await fetch(`http://127.0.0.1:8000/api/posts/${ID}`, { const resp = await this.$axios.get(`/posts/${ID}`, {
method: "GET", method: "GET",
headers: { headers: {
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal("token"), Authorization: this.$auth.$storage.getUniversal("token"),
}, },
}).then((response) => {
return response.json()
}) })
this.sTitle = resp.data.title console.log(resp.data)
this.sContent = resp.data.content this.sTitle = resp.data.data.title
this.sCategoryId = resp.data.category_id this.sContent = resp.data.data.content
this.sUserId = resp.data.user_id this.sCategoryId = resp.data.data.category_id
this.sStatus = resp.data.status this.sUserId = resp.data.data.user_id
this.sImages = resp.data.images this.sStatus = resp.data.data.status
this.sImages = resp.data.data.images
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
...@@ -492,7 +491,7 @@ export default { ...@@ -492,7 +491,7 @@ export default {
}, },
updatePost() { updatePost() {
const self = this const self = this
axios this.$axios
.post( .post(
`/posts/update/${this?.eId}`, `/posts/update/${this?.eId}`,
{ {
...@@ -532,5 +531,4 @@ export default { ...@@ -532,5 +531,4 @@ export default {
}; };
</script> </script>
<style> <style></style>
</style>
...@@ -558,24 +558,20 @@ export default { ...@@ -558,24 +558,20 @@ export default {
async showProduct(item) { async showProduct(item) {
const ID = item.id const ID = item.id
try { try {
const resp = await fetch(`http://127.0.0.1:8000/api/products/${ID}`, { const resp = await this.$axios.get(`/products/${ID}`, {
method: "GET", method: "GET",
headers: { headers: {
"Content-Type": "multipart/form-data", "Content-Type": "multipart/form-data",
"Authorization": this.$auth.$storage.getUniversal("token") Authorization: this.$auth.$storage.getUniversal("token"),
} },
}).then((response) => {
return response.json()
}) })
this.sName = resp.data.name this.sName = resp.data.data.name
this.sPrice = resp.data.price this.sPrice = resp.data.data.price
this.sCategoryId = resp.data.category_id this.sCategoryId = resp.data.data.category_id
this.sDescription = resp.data.description this.sDescription = resp.data.data.description
this.sStock = resp.data.stock this.sStock = resp.data.data.stock
this.sVariants = resp.data.variants this.sVariants = resp.data.data.variants
this.sImages = resp.data.images this.sImages = resp.data.data.images
console.log(this.sVariants)
console.log(this.sImages)
} catch (error) { } catch (error) {
console.log(error) console.log(error)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment