import { AxiosInstance , AxiosRequestConfig } from 'axios' ; import { errorHandler } from 'contentful-sdk-core' ; function getBaseUrl ( http ) { return http . defaults . baseURL ?. split ( '/spaces' ) [ 0 ] ; } export function get < T = any > ( http , url , config ? ) { return http . get < T > ( url , { baseURL : getBaseUrl ( http ) , ... config , } ) . then ( ( response ) => response . data , errorHandler ) ; } export function patch < T = any > ( http , url , payload ? , config ? ) { return http . patch < T > ( url , payload , { baseURL : getBaseUrl ( http ) , ... config , } ) . then ( ( response ) => response . data , errorHandler ) ; } export function post < T = any > ( http , url , payload ? , config ? ) { return http . post < T > ( url , payload , { baseURL : getBaseUrl ( http ) , ... config , } ) . then ( ( response ) => response . data , errorHandler ) ; } export function put < T = any > ( http , url , payload ? , config ? ) { return http . put < T > ( url , payload , { baseURL : getBaseUrl ( http ) , ... config , } ) . then ( ( response ) => response . data , errorHandler ) ; } export function del < T = any > ( http , url , config ? ) { return http . delete < T > ( url , { baseURL : getBaseUrl ( http ) , ... config , } ) . then ( ( response ) => response . data , errorHandler ) ; } export function http < T = any > ( http , url , config ? ) { return http ( url , { baseURL : getBaseUrl ( http ) , ... config , } ) . then ( ( response ) => response . data as T , errorHandler ) ; }