Skip to content
Snippets Groups Projects
Commit 6cf5ffe8 authored by Ramesh Kumar's avatar Ramesh Kumar
Browse files

TMSS-438: Updating request header with token

parent 03201855
No related branches found
No related tags found
1 merge request!336Resolve TMSS-543
import Axios from "axios";
import AuthService from "../services/auth.service"; import AuthService from "../services/auth.service";
const axios = require('axios');
/** /**
* Global functions to authenticate user and get user details from browser local storage. * Global functions to authenticate user and get user details from browser local storage.
*/ */
...@@ -10,6 +13,7 @@ const Auth = { ...@@ -10,6 +13,7 @@ const Auth = {
if (user) { if (user) {
user = JSON.parse(user); user = JSON.parse(user);
if (user.token) { if (user.token) {
axios.defaults.headers.common['Authorization'] = `Token ${user.token}`;
return true; return true;
} }
} }
......
...@@ -18,6 +18,15 @@ const AuthService = { ...@@ -18,6 +18,15 @@ const AuthService = {
} catch(error) { } catch(error) {
console.error(error); console.error(error);
} }
},
isValidToken: async(token) => {
try {
axios.defaults.headers.common['Authorization'] = `Token ${token}`;
const response = await axios.get("/api/subtask_type/?limit=1&offset=1");
console.log(response);
} catch(error) {
console.error(error);
}
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment