-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #277 from moul/dev/appigram/ghost-nodes
feat: Ghost nodes
- Loading branch information
Showing
19 changed files
with
836 additions
and
644 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { baseApi } from './index' | ||
import baseApi from './index' | ||
|
||
export function fetchDepviz(url, params) { | ||
return baseApi.get(`${url}`, params) | ||
} | ||
const fetchDepviz = (url, params) => baseApi.get(`${url}`, params) | ||
|
||
export default fetchDepviz |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,40 @@ | ||
import axios from 'axios' | ||
import store from '../utils/store' | ||
|
||
export const baseApi = axios.create({ | ||
let retryCounter = 0 | ||
|
||
const baseApi = axios.create({ | ||
baseURL: process.env.API_URL, | ||
}) | ||
|
||
// Add a response interceptor | ||
baseApi.interceptors.request.use( | ||
(config) => { | ||
const auth = store.getItem('auth_token') | ||
config.headers.Authorization = `Basic ${btoa(`depviz:${auth}`)}` | ||
return config | ||
const newConfig = config | ||
newConfig.headers.Authorization = `Basic ${btoa(`depviz:${store.getItem('auth_token')}`)}` | ||
return newConfig | ||
}, | ||
) | ||
|
||
// Add a response interceptor | ||
baseApi.interceptors.response.use((response) => response, | ||
(error) => { | ||
const status = error.response ? error.response.status : null | ||
const newError = error | ||
const status = newError.response ? newError.response.status : null | ||
|
||
if (status === 401) { | ||
const auth = process.env.AUTH_TOKEN | ||
store.setItem('auth_token', auth) | ||
error.config.headers.Authorization = `Basic ${btoa(`depviz:${auth}`)}` | ||
return baseApi.request(error.config) | ||
// }); | ||
if (process.env.AUTH_TOKEN) { | ||
store.setItem('auth_token', process.env.AUTH_TOKEN) | ||
newError.config.headers.Authorization = `Basic ${btoa(`depviz:${process.env.AUTH_TOKEN}`)}` | ||
} | ||
retryCounter += 1 | ||
if (retryCounter < 4) { // Allow 3 attempts to request | ||
return baseApi.request(newError.config) | ||
} | ||
} | ||
console.error('failed', error, status, error) | ||
alert(`failed: ${error}`) | ||
return Promise.reject(error) | ||
console.error('failed', newError, status, newError) | ||
alert(`failed: ${newError}`) | ||
return Promise.reject(newError) | ||
}) | ||
|
||
export default baseApi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.