Commit 28df8be7 authored by TTS Kieu Tuan Anh's avatar TTS Kieu Tuan Anh

add bearer token

parent 66e7f51a
......@@ -56,7 +56,7 @@ export default {
method: "POST",
headers: {
"Content-Type": "application/json",
accept: "application/json",
"accept": "application/json",
},
body: JSON.stringify({
token: this.$auth.$storage.getUniversal("token"),
......
......@@ -308,7 +308,11 @@ export default {
},
getCategories() {
this.$axios
.get("/categories/")
.get("/categories/",{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => (this.categories = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -319,17 +323,20 @@ export default {
const image = Array.from(set)
const self = this
this.$axios
.post('/categories/',{
.post('/categories/',
{
name: this.name,
ordering: this.ordering,
parent_id: this.parent_id,
images: image,
}, {
},
{
headers: {
"Content-Type": "multipart/form-data",
"Authorization": this.$auth.$storage.getUniversal("token")
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
}
})
)
.then(response => {
this.$bvModal.hide('modal-create')
self.$toast.success('Category created successfully!', {
......@@ -362,7 +369,13 @@ export default {
if(confirm("Do you really want to delete?")){
try{
this.$axios
.delete(`/categories/${ID}`)
.delete(`/categories/${ID}`,
{
headers: {
"Content-Type": "multipart/form-data",
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
})
.then(response => {
this.categories.splice(this.editedIndex, 1)
self.$toast.success('Category deleted successfully!',{
......@@ -397,16 +410,19 @@ export default {
console.log(this?.eID)
try{
this.$axios
.post(`categories/update/${this?.eID}`,{
.post(`categories/update/${this?.eID}`,
{
name: this.eName,
ordering: this.eOrdering,
parent_id: this.eParentId,
images: image }, {
images: image },
{
headers: {
"Content-Type": "multipart/form-data",
"Authorization": this.$auth.$storage.getUniversal("token")
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}
}
} )
)
.then(response => {
self.$toast.success('User updated successfully!',{
duration: 3000
......
......@@ -386,7 +386,11 @@ export default {
},
getCategories() {
this.$axios
.get("/categories/")
.get("/categories/",{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => (this.categories = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -394,7 +398,11 @@ export default {
},
getposts() {
this.$axios
.get("/posts/")
.get("/posts/",{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => (this.posts = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -415,7 +423,7 @@ export default {
{
headers: {
"Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal("token"),
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
}
)
......@@ -442,7 +450,11 @@ export default {
this.editedIndex = this.posts.indexOf(index)
if (confirm("Do you really want to delete?")) {
this.$axios
.delete(`/posts/${ID}`)
.delete(`/posts/${ID}`,{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => {
this.posts.splice(this.editedIndex, 1)
self.$toast.success("Post deleted successfully!", {
......@@ -464,7 +476,7 @@ export default {
method: "GET",
headers: {
"Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal("token"),
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
})
console.log(resp.data)
......@@ -505,7 +517,7 @@ export default {
{
headers: {
"Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal("token"),
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
}
)
......
......@@ -487,7 +487,11 @@ export default {
},
getCategories() {
this.$axios
.get("/categories/")
.get("/categories/",{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => (this.categories = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -495,7 +499,11 @@ export default {
},
getProducts() {
this.$axios
.get("/products/")
.get("/products/",{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then((response) => (this.products = response.data.data))
.catch(function (error) {
console.log(error)
......@@ -516,7 +524,7 @@ export default {
}, {
headers: {
'Content-Type': 'multipart/form-data',
'Authorization': this.$auth.$storage.getUniversal('token')
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}
})
.then(response => {
......@@ -543,7 +551,11 @@ export default {
if(confirm("Do you really want to delete?")){
try{
this.$axios
.delete(`/products/${ID}`)
.delete(`/products/${ID}`,{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}})
.then(response => {
this.products.splice(this.editedIndex, 1)
self.$toast.success('Category deleted successfully!',{
......@@ -562,7 +574,7 @@ export default {
method: "GET",
headers: {
"Content-Type": "multipart/form-data",
Authorization: this.$auth.$storage.getUniversal("token"),
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
})
this.sName = resp.data.data.name
......@@ -602,9 +614,10 @@ export default {
}, {
headers: {
"Content-Type": "multipart/form-data",
"Authorization": this.$auth.$storage.getUniversal("token")
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
}
}
} )
)
.then(response => {
self.$toast.success('User updated successfully!',{
duration: 3000
......
......@@ -86,7 +86,7 @@ export default {
confirm_password: this.confirm_password,
}),
});
this.$router.push("/");
this.$router.push("/login");
},
},
};
......
......@@ -295,7 +295,12 @@ export default {
},
getUsers() {
this.$axios
.get('/users/')
.get('/users/',{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
})
.then((response) => (this.users = response.data.data.data))
.catch(function (error) {
console.log(error)
......@@ -304,14 +309,19 @@ export default {
createUser() {
const self = this
this.$axios
.post('/users/',{
headers: {
'Content-Type': 'application/json'
},
.post('/users/',
{
email: this.email,
password: this.password,
name:this.name,
})
},
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
}
)
.then(response => {
// $bvModal.hide('modal-login');
this.$bvModal.hide('modal-login')
......@@ -338,7 +348,12 @@ export default {
if(confirm("Do you really want to delete?")){
try{
this.$axios
.delete(`/users/${userID}`)
.delete(`/users/${userID}`,{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
})
.then(response => {
console.log(response.data)
this.users.splice(this.editedIndex, 1)
......@@ -366,10 +381,19 @@ export default {
console.log(this?.eID)
try{
this.$axios
.put(`/users/${this?.eID}`,{
.put(`/users/${this?.eID}`,
{
email: this.eEmail,
password: this.ePassword,
name:this.eName,} )
name:this.eName,
},
{
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${this.$auth.$storage.getUniversal("token")}`,
},
}
)
.then(response => {
self.$toast.success('User updated successfully!',{
duration: 3000
......
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