Skip to content

Instantly share code, notes, and snippets.

@Tiagoperes
Created May 22, 2019 17:13
Show Gist options
  • Save Tiagoperes/e83c87f2bf0625c69baae2de6964d642 to your computer and use it in GitHub Desktop.
Save Tiagoperes/e83c87f2bf0625c69baae2de6964d642 to your computer and use it in GitHub Desktop.
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