Created
May 22, 2019 17:13
-
-
Save Tiagoperes/e83c87f2bf0625c69baae2de6964d642 to your computer and use it in GitHub Desktop.
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
import axios from 'axios' | |
const api = axios.create({ | |
mode: 'cors', | |
baseURL: 'http://localhost:3000', | |
}) | |
// if we don't write the next line, our resources will receive the entire response in the data field. We don't want that. | |
api.interceptors.response.use(response => response.data) | |
const loadProfile = () => api.get('/profile') | |
const saveProfile = data => api.put('/profile', data) | |
const loadWallet = () => api.get('/wallet') | |
const createCardForWallet = data => api.post('/wallet', data) | |
const removeCardFromWallet = id => api.delete('/wallet', { id }) | |
const createOrder = data => api.post('/order', data) | |
export default { | |
loadProfile, | |
saveProfile, | |
loadWallet, | |
loadCatalog, | |
createCardForWallet, | |
removeCardFromWallet, | |
createOrder, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment