feat: tambah error logger ke monitoring dashboard dengan offline queue
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
14
lib/api.ts
14
lib/api.ts
@@ -1,10 +1,22 @@
|
||||
import axios from 'axios';
|
||||
import axios, { AxiosError } from 'axios';
|
||||
import Constants from 'expo-constants';
|
||||
import { logError } from '@/lib/errorLogger';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: Constants?.expoConfig?.extra?.URL_API
|
||||
});
|
||||
|
||||
api.interceptors.response.use(
|
||||
(response) => response,
|
||||
(error: AxiosError) => {
|
||||
const status = error.response?.status;
|
||||
const url = error.config?.url ?? 'unknown endpoint';
|
||||
const description = `API error ${status ?? 'network'} on ${url}`;
|
||||
logError(description, error);
|
||||
return Promise.reject(error);
|
||||
}
|
||||
);
|
||||
|
||||
export const apiCheckPhoneLogin = async (body: { phone: string }) => {
|
||||
const response = await api.post('/auth/login', body)
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user