{"action":"created","issue":{"url":"https://api.github.com/repos/ratiw/vuetable-2/issues/365","repository_url":"https://api.github.com/repos/ratiw/vuetable-2","labels_url":"https://api.github.com/repos/ratiw/vuetable-2/issues/365/labels{/name}","comments_url":"https://api.github.com/repos/ratiw/vuetable-2/issues/365/comments","events_url":"https://api.github.com/repos/ratiw/vuetable-2/issues/365/events","html_url":"https://github.com/ratiw/vuetable-2/issues/365","id":289932461,"number":365,"title":"Attaching bearer token in every datatable api mode request","user":{"login":"Geowan","id":20105002,"avatar_url":"https://avatars1.githubusercontent.com/u/20105002?v=4","gravatar_id":"","url":"https://api.github.com/users/Geowan","html_url":"https://github.com/Geowan","followers_url":"https://api.github.com/users/Geowan/followers","following_url":"https://api.github.com/users/Geowan/following{/other_user}","gists_url":"https://api.github.com/users/Geowan/gists{/gist_id}","starred_url":"https://api.github.com/users/Geowan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Geowan/subscriptions","organizations_url":"https://api.github.com/users/Geowan/orgs","repos_url":"https://api.github.com/users/Geowan/repos","events_url":"https://api.github.com/users/Geowan/events{/privacy}","received_events_url":"https://api.github.com/users/Geowan/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-01-19T10:41:06Z","updated_at":"2018-04-29T06:04:58Z","closed_at":null,"author_association":"NONE","body":"How do i attach a bearer token to each http request sent by the datatable in the api mode.\r\nThe token is saved in the localstorage as io would also want to listen for cases of 401 and redirrect to login page\r\n\r\nI have set up  vue resource already like\r\n         Vue.use(VueResource);\r\n          Vue.http.options.root = appdetails.apiurl\r\n        Vue.http.interceptors.push(function (request, next) {\r\n           request.headers.set('Authorization', `Bearer `+tokenservice.gettoken(tokenservice.accesstoken));\r\n          next()\r\n        });\r\n\r\nNow in my vuetable\r\n\r\n         <vue-table ref=\"vuetable\"\r\n                           :api-url=\"apiurl\" \r\n\r\n         />\r\n           apiurl:appdetails.apiurl+\"/users\"\r\n\r\n\r\nNow the above fails whenenever the route is protected by auth api in laravel.\r\n\r\nHow do i go about this."},"comment":{"url":"https://api.github.com/repos/ratiw/vuetable-2/issues/comments/385228373","html_url":"https://github.com/ratiw/vuetable-2/issues/365#issuecomment-385228373","issue_url":"https://api.github.com/repos/ratiw/vuetable-2/issues/365","id":385228373,"user":{"login":"kedcomsci","id":23306577,"avatar_url":"https://avatars1.githubusercontent.com/u/23306577?v=4","gravatar_id":"","url":"https://api.github.com/users/kedcomsci","html_url":"https://github.com/kedcomsci","followers_url":"https://api.github.com/users/kedcomsci/followers","following_url":"https://api.github.com/users/kedcomsci/following{/other_user}","gists_url":"https://api.github.com/users/kedcomsci/gists{/gist_id}","starred_url":"https://api.github.com/users/kedcomsci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kedcomsci/subscriptions","organizations_url":"https://api.github.com/users/kedcomsci/orgs","repos_url":"https://api.github.com/users/kedcomsci/repos","events_url":"https://api.github.com/users/kedcomsci/events{/privacy}","received_events_url":"https://api.github.com/users/kedcomsci/received_events","type":"User","site_admin":false},"created_at":"2018-04-29T06:04:58Z","updated_at":"2018-04-29T06:04:58Z","author_association":"NONE","body":"@sherlyseptiani try you use this in main.js\r\n\r\n```\r\naxios.defaults.baseURL = process.env.API_LOCATION || 'http://localhost'\r\nif (localStorage.getItem('auth') != null) {\r\n  let auth = JSON.parse(localStorage.getItem('auth'))\r\n  axios.defaults.headers.common['Authorization'] = 'Bearer ' + auth.Token\r\n}\r\n```\r\nand [see this code for use your api](https://codesandbox.io/s/239v6w2vkp)"}}
{"actor":{"display_login":"kedcomsci"}}