refactoring

This commit is contained in:
2022-05-31 15:14:15 +03:00
parent d220a39665
commit 4bdfdd58ec
11 changed files with 57 additions and 106 deletions

View File

@ -6,7 +6,7 @@ export const withAuthRedirect =
: link
return actionCall(linkWithParams, body)
.then((res) => {
if (res.status && res.status == 401) {
if (res.status && res.status === 401) {
localStorage.clear()
logout && logout()
history.push(role === 'ROLE_DEV' ? '/authdev' : '/auth')

View File

@ -25,7 +25,6 @@ export const fetchAuth = async ({
dispatch,
catchError
}) => {
const baseURL = process.env.REACT_APP_BASE_URL
const apiURL = process.env.REACT_APP_API_URL
try {
const response = await fetch(`${apiURL}/api/user/login`, {
@ -33,7 +32,7 @@ export const fetchAuth = async ({
mode: 'cors',
headers: {
'Access-Control-Request-Headers': 'authorization',
'Content-Type': 'application/json',
'Content-Type': 'application/json'
// Origin: `http://localhost`
},
body: JSON.stringify({
@ -98,7 +97,7 @@ export const fetchGet = withAuthRedirect(async (link) => {
})
export const fetchPost = withAuthRedirect(async (link, body) => {
console.log('i',body)
console.log('i', body)
try {
const response = await fetch(link, {
method: 'POST',
@ -106,7 +105,7 @@ export const fetchPost = withAuthRedirect(async (link, body) => {
Authorization: `Bearer ${localStorage.getItem('auth_token')}`,
'Content-Type': 'application/json',
//Origin: `http://localhost:3000`
Origin: `${process.env.REACT_APP_BASE_URL}`,
Origin: `${process.env.REACT_APP_BASE_URL}`
},
body: JSON.stringify(body)
})