import axios from 'axios' ; import { API_ROOT } from '../config' ; export const api = { get ( url ) { return axios . get ( `${ API_ROOT }${ url }` ) . then ( ( response ) => { return response . data ?. data ; } ) . catch ( ( error ) => { return Promise . reject ( error ?. response ?. data || error ?. response || error ) ; } ) ; } , getFullResponse ( url , params ? ) { return axios . get ( `${ API_ROOT }${ url }` , { params , } ) . then ( ( response ) => response . data ) . catch ( ( error ) => { return Promise . reject ( error ?. response ?. data || error ?. response || error ) ; } ) ; } , put ( url , payload ) { return axios . put ( `${ API_ROOT }${ url }` , payload ) . then ( ( response ) => response . data ?. data ) . catch ( ( error ) => { return Promise . reject ( error ?. response ?. data || error ?. response || error ) ; } ) ; } , post ( url , payload ) { return axios . post ( `${ API_ROOT }${ url }` , payload ) . then ( ( response ) => response . data ?. data ) . catch ( ( error ) => { return Promise . reject ( error ?. response ?. data || error ?. response || error ) ; } ) ; } , } ;