Tabs -> spaces
I have become my own worst enemy
This commit is contained in:
parent
e94559c4f6
commit
fdb7f0ef67
49 changed files with 2424 additions and 2424 deletions
|
|
@ -1,45 +1,45 @@
|
|||
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',
|
||||
},
|
||||
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 handleError = error => {
|
||||
if (error.response && error.response.status) {
|
||||
console.log('[Error handler] res:', error.response);
|
||||
}
|
||||
return Promise.reject(error.response);
|
||||
if (error.response && error.response.status) {
|
||||
console.log('[Error handler] res:', 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);
|
||||
} catch (error) {
|
||||
return handleError(error);
|
||||
}
|
||||
},
|
||||
post: async (endpoint, data, options = {}) => {
|
||||
try {
|
||||
const response = await instance.post(endpoint, data, options);
|
||||
return Promise.resolve(response);
|
||||
} catch (error) {
|
||||
return handleError(error);
|
||||
}
|
||||
},
|
||||
patch: async (endpoint, data) => {
|
||||
try {
|
||||
const response = await instance.patch(endpoint, data);
|
||||
return Promise.resolve(response);
|
||||
} catch (error) {
|
||||
return handleError(error);
|
||||
}
|
||||
},
|
||||
get: async (endpoint, data) => {
|
||||
try {
|
||||
const response = await instance.get(endpoint, data);
|
||||
return Promise.resolve(response);
|
||||
} catch (error) {
|
||||
return handleError(error);
|
||||
}
|
||||
},
|
||||
post: async (endpoint, data, options = {}) => {
|
||||
try {
|
||||
const response = await instance.post(endpoint, data, options);
|
||||
return Promise.resolve(response);
|
||||
} catch (error) {
|
||||
return handleError(error);
|
||||
}
|
||||
},
|
||||
patch: async (endpoint, data) => {
|
||||
try {
|
||||
const response = await instance.patch(endpoint, data);
|
||||
return Promise.resolve(response);
|
||||
} catch (error) {
|
||||
return handleError(error);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export default api;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue