import axios from 'axios'; import { env } from '../../config/env'; import { attachInterceptors } from './interceptors'; /** * Single client for the CBS backend. The response interceptor unwraps the * `{ success, message, data }` envelope, so callers read `response.data` as the * endpoint payload and a `success: false` body arrives as a thrown * `CbsApiError` carrying the code to switch on. */ export const apiClient = axios.create({ baseURL: env.apiBaseUrl, timeout: 15000, headers: { 'Content-Type': 'application/json', }, }); attachInterceptors(apiClient); if (__DEV__ && env.devMockBackend) { // Required lazily so a release bundle never evaluates the fixtures. apiClient.defaults.adapter = require('./devMockAdapter').devMockAdapter; }