Update components
This commit is contained in:
parent
4382f559f3
commit
a67aee24dc
95 changed files with 3901 additions and 12032 deletions
|
|
@ -1,27 +1,19 @@
|
|||
import axios from 'axios';
|
||||
|
||||
export const instance = axios.create({
|
||||
baseURL: process.env.NODE_ENV === 'production' ? 'https://api-dot-crabfit.uc.r.appspot.com' : 'http://localhost:8080',
|
||||
timeout: 1000 * 300,
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
const API_URL = process.env.NODE_ENV === 'production' ? 'https://api-dot-crabfit.uc.r.appspot.com' : 'http://localhost:8080'
|
||||
|
||||
const handleError = error => {
|
||||
if (error.response && error.response.status) {
|
||||
console.log('[Error handler] res:', error.response);
|
||||
console.error('[Error handler] res:', error.response)
|
||||
}
|
||||
return Promise.reject(error.response);
|
||||
};
|
||||
return Promise.reject(error.response)
|
||||
}
|
||||
|
||||
const api = {
|
||||
get: async (endpoint, data) => {
|
||||
try {
|
||||
const response = await instance.get(endpoint, data);
|
||||
return Promise.resolve(response);
|
||||
const response = await fetch(API_URL + endpoint)
|
||||
return Promise.resolve(response)
|
||||
} catch (error) {
|
||||
return handleError(error);
|
||||
return handleError(error)
|
||||
}
|
||||
},
|
||||
post: async (endpoint, data, options = {}) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue