Add:
- context/ - hook/ - types/ ### No Issue
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import axios, { AxiosInstance } from "axios";
|
||||
import Constants from "expo-constants";
|
||||
|
||||
const API_BASE_URL = Constants.expoConfig?.extra?.API_BASE_URL;
|
||||
|
||||
const api: AxiosInstance = axios.create({
|
||||
// const API_BASE_URL = process.env.API_BASE_URL
|
||||
|
||||
export const apiClient: AxiosInstance = axios.create({
|
||||
baseURL: API_BASE_URL,
|
||||
timeout: 10000,
|
||||
headers: {
|
||||
@@ -11,26 +12,40 @@ const api: AxiosInstance = axios.create({
|
||||
},
|
||||
});
|
||||
|
||||
// apiClient.interceptors.request.use(
|
||||
// (config) => {
|
||||
// const token = localStorage.getItem("token");
|
||||
// if (token) {
|
||||
// config.headers.Authorization = `Bearer ${token}`;
|
||||
// }
|
||||
// return config;
|
||||
// },
|
||||
// (error) => {
|
||||
// return Promise.reject(error);
|
||||
// }
|
||||
// );
|
||||
|
||||
export async function apiVersion() {
|
||||
console.log("API_BASE_URL", API_BASE_URL);
|
||||
const response = await api.get("/version");
|
||||
const response = await apiClient.get("/version");
|
||||
console.log("Response version", response.data);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function apiLogin({ nomor }: { nomor: string }) {
|
||||
const response = await api.post("/auth/login", {
|
||||
const response = await apiClient.post("/auth/login", {
|
||||
nomor: nomor,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function apiCheckCodeOtp({ kodeId }: { kodeId: string }) {
|
||||
const response = await api.get(`/auth/check/${kodeId}`);
|
||||
const response = await apiClient.get(`/auth/check/${kodeId}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function apiValidationCode({ nomor }: { nomor: string }) {
|
||||
const response = await api.post(`/auth/validasi`, {
|
||||
const response = await apiClient.post(`/auth/validasi`, {
|
||||
nomor: nomor,
|
||||
});
|
||||
return response.data;
|
||||
@@ -41,7 +56,7 @@ export async function apiRegister({
|
||||
}: {
|
||||
data: { nomor: string; username: string };
|
||||
}) {
|
||||
const response = await api.post(`/auth/register`, {
|
||||
const response = await apiClient.post(`/auth/register`, {
|
||||
data: data,
|
||||
});
|
||||
return response.data;
|
||||
|
||||
Reference in New Issue
Block a user