import axios from 'axios'

export const storageAPI = axios.create({
  baseURL: window.config.STORAGE_API,
  timeout: 5000
})

export const orchestratorAPI = axios.create({
  baseURL: window.config.ORCHESTRATOR_API,
  timeout: 5000
})

export default {
  storageAPI: async call => {
    try {
      const { data } = await storageAPI(call)
      return data
    } catch (e) {
      console.error(e)
      throw new Error('Unknown error')
    }
  },
  orchestratorAPI: async call => {
    try {
      const { data } = await orchestratorAPI(call)
      return data
    } catch (e) {
      console.error(e)
      throw new Error('Unknown error')
    }
  }
}
