Commit 543d64a1 authored by Khalid Ali's avatar Khalid Ali
Browse files

Get CSRF token from home page

parent 2ad4af2d
Pipeline #4051 failed with stages
in 2 minutes and 46 seconds
......@@ -35,13 +35,5 @@ export default new Router({
title: 'SRCT Bookshare - Create Listing',
},
},
{
path: '/login',
name: 'login',
component: () => import ('./views/Login.vue'),
meta: {
title: 'SRCT Bookshare - Login',
},
}
],
});
......@@ -161,13 +161,13 @@ export default class CreateListing extends Vue {
// }
mounted() {
API.get("/bs").then(function (response) {
console.log(response.headers);
}).catch(function (error) {
const token = error.response.headers["x-csrf-token"];
if (error.response.headers["x-csrf-token"] != null) {
API.get("/").then(function (response) {
const token = response.headers["x-csrf-token"];
if (response.headers["x-csrf-token"] != null) {
localStorage.setItem("csrf_token", token);
}
}).catch(function (error) {
console.log(error.response);
})
}
......
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