diff --git a/frontend/src/auth/index.js b/frontend/src/auth/index.js
index 58ff291..f297e42 100644
--- a/frontend/src/auth/index.js
+++ b/frontend/src/auth/index.js
@@ -57,5 +57,9 @@ export default {
return {
'Authorization': 'Bearer ' + localStorage.getItem('token')
}
+ },
+
+ getToken () {
+ return localStorage.getItem('token')
}
}
diff --git a/frontend/src/components/Books.vue b/frontend/src/components/Books.vue
index 1a846f2..690f217 100644
--- a/frontend/src/components/Books.vue
+++ b/frontend/src/components/Books.vue
@@ -9,12 +9,19 @@
{{ error.message }}
-
+
{{ error.response.Message }}
+
+
+
+
+
+ {{ success }}
@@ -98,7 +105,8 @@ export default {
],
loading: false,
paginate: ['books'],
- error: ''
+ error: '',
+ success: ''
}
},
created () {
@@ -165,6 +173,18 @@ export default {
},
deleteBook (obj) {
console.log(obj.ID.content, 'delete')
+ HTTP.delete('books/' + obj.ID.content)
+ .then(response => {
+ console.log(response)
+ if (response.status === 200 && response.data.Message === 'success') {
+ this.success = 'The book was deleted successfully.'
+ this.loadBooks()
+ }
+ })
+ .catch(e => {
+ // TODO: proper error handling
+ console.log(e)
+ })
},
editBook (id) {
console.log(id, 'edit')
diff --git a/frontend/src/http-common/index.js b/frontend/src/http-common/index.js
index 40d5709..fde5214 100644
--- a/frontend/src/http-common/index.js
+++ b/frontend/src/http-common/index.js
@@ -1,8 +1,9 @@
import axios from 'axios'
+// import auth from '../auth'
export const HTTP = axios.create({
baseURL: `http://localhost:8082/api/v1/`,
headers: {
- Authorization: 'Bearer {token}'
+ 'Authorization': 'Bearer ' + localStorage.getItem('token')
}
})