Add:
- service/api-client/ : api route setting
- service/api-config.ts : api base url

Profil & User
Fix:
- auth logic
- crate profile

### No Issue
This commit is contained in:
2025-08-22 17:32:48 +08:00
parent 014cf387fd
commit ebcf16efba
14 changed files with 195 additions and 138 deletions

View File

@@ -0,0 +1,8 @@
import { apiConfig } from "../api-config";
export async function apiCreateProfile(data: any) {
const response = await apiConfig.post(`/mobile/profile`, {
data: data,
});
return response;
}

View File

@@ -0,0 +1,7 @@
import { apiConfig } from "../api-config";
export async function apiUser(id: string) {
const response = await apiConfig.get(`/user/${id}`);
return response.data;
}

View File

@@ -3,7 +3,7 @@ import axios, { AxiosInstance } from "axios";
import Constants from "expo-constants";
const API_BASE_URL = Constants.expoConfig?.extra?.API_BASE_URL;
export const apiClient: AxiosInstance = axios.create({
export const apiConfig: AxiosInstance = axios.create({
baseURL: API_BASE_URL,
});
@@ -16,7 +16,7 @@ export const apiClient: AxiosInstance = axios.create({
// "/auth/logout", // opsional, tergantung kebutuhan
// ];
apiClient.interceptors.request.use(
apiConfig.interceptors.request.use(
async (config) => {
const token = await AsyncStorage.getItem("authToken");
if (token) {
@@ -35,25 +35,25 @@ apiClient.interceptors.request.use(
export async function apiVersion() {
// console.log("API_BASE_URL", API_BASE_URL);
const response = await apiClient.get("/version");
const response = await apiConfig.get("/version");
// console.log("Response version", JSON.stringify(response.data, null, 2));
return response.data;
}
export async function apiLogin({ nomor }: { nomor: string }) {
const response = await apiClient.post("/auth/login", {
const response = await apiConfig.post("/auth/login", {
nomor: nomor,
});
return response.data;
}
export async function apiCheckCodeOtp({ kodeId }: { kodeId: string }) {
const response = await apiClient.get(`/auth/check/${kodeId}`);
const response = await apiConfig.get(`/auth/check/${kodeId}`);
return response.data;
}
export async function apiValidationCode({ nomor }: { nomor: string }) {
const response = await apiClient.post(`/auth/validasi`, {
const response = await apiConfig.post(`/auth/validasi`, {
nomor: nomor,
});
return response.data;
@@ -64,7 +64,7 @@ export async function apiRegister({
}: {
data: { nomor: string; username: string };
}) {
const response = await apiClient.post(`/auth/register`, {
const response = await apiConfig.post(`/auth/register`, {
data: data,
});
return response.data;