text: 
  import { authHeader, config } from '../_helpers';
  import axios from 'axios';
  export const userService = {
      login,
      logout,
      register,
      getAll,
      getById,
      update,
      delete: _delete
  };
  
  function login(email, password) {
      const requestOptions = {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({ email, password })
      };
      const user = {
          email, password
      }
      return axios.post(`http://192.168.110.111:8000/api/Members/login`, user)
          .then(user => {
              localStorage.setItem('user', JSON.stringify(user));
              setAxiosHeader(user.data.id)
              return user;
          });
  }
  
  const setAxiosHeader = (token) => {
      if (token) {
          axios.defaults.headers.common['Authorization'] = `${token}`;
      } else {
          axios.defaults.headers.common['Authorization'] = "";
      }
  }
  
  function logout() {
      localStorage.removeItem('user');
  }
  
  function getAll() {
      const requestOptions = {
          method: 'GET',
          headers: authHeader()
      };
  
      return fetch(`${config.apiUrl}/users`, requestOptions).then(handleResponse);
  }
  
  function getById(id) {
      const requestOptions = {
          method: 'GET',
          headers: authHeader()
      };
  
      return fetch(`${config.apiUrl}/users/${id}`, requestOptions).then(handleResponse);
  }
  
  function register(user) {
      const requestOptions = {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify(user)
      };
  
      return fetch(`${config.apiUrl}/users/register`, requestOptions).then(handleResponse);
  }
  
  function update(user) {
      const requestOptions = {
          method: 'PUT',
          headers: { ...authHeader(), 'Content-Type': 'application/json' },
          body: JSON.stringify(user)
      };
  
      return fetch(`${config.apiUrl}/users/${user.id}`, requestOptions).then(handleResponse);;
  }
  
  // prefixed function name with underscore because delete is a reserved word in javascript
  function _delete(id) {
      const requestOptions = {
          method: 'DELETE',
          headers: authHeader()
      };
  
      return fetch(`${config.apiUrl}/users/${id}`, requestOptions).then(handleResponse);
  }
  
  function handleResponse(response) {
      return response.text().then(text => {
          const data = text && JSON.parse(text);
          if (!response.ok) {
              if (response.status === 401) {
                  logout();
              }
  
              const error = (data && data.message) || response.statusText;
              return Promise.reject(error);
          }
  
          return data;
      });
  }
  
  
  if (localStorage.getItem('user')) {
      let user = localStorage.getItem('user');
      if (user && user.data) {
          setAxiosHeader(user.data.id);
      }
  } else {
      logout()
  }
  