1import store from './store';
2
3export function getProtectedThing() {
4 // grab current state
5 const state = store.getState();
6
7 // get the JWT token out of it
8 // (obviously depends on how your store is structured)
9 const authToken = state.currentUser.token;
10
11 // Pass the token to the server
12 return fetch('/user/thing', {
13 method: 'GET',
14 headers: {
15 Authorization: `Bearer ${authToken}`
16 }
17 }).then(res => res.json());
18}
19