Refactor authentication with Context
This commit is contained in:
7
src/helpers/authContext.js
Normal file
7
src/helpers/authContext.js
Normal file
@@ -0,0 +1,7 @@
|
||||
import { createContext, useContext } from 'react';
|
||||
|
||||
export const AuthContext = createContext();
|
||||
|
||||
export function useAuth() {
|
||||
return useContext(AuthContext);
|
||||
}
|
||||
9
src/helpers/http-common.js
Normal file
9
src/helpers/http-common.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import axios from 'axios';
|
||||
import { API_URL } from '../constants';
|
||||
|
||||
export const backend = axios.create({
|
||||
baseURL: API_URL,
|
||||
headers: {
|
||||
'Content-type': 'application/json',
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user