API
Add: - lib/api.ts ### No Issue
This commit is contained in:
23
lib/api.ts
Normal file
23
lib/api.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
const API_BASE = (path: string) => {
|
||||
const url = "https://stg-hipmi.wibudev.com/";
|
||||
// const url = "http://10.169.174.254:3000/";
|
||||
return `${url}/${path}`;
|
||||
};
|
||||
|
||||
export async function apiVersion() {
|
||||
const response = await fetch(API_BASE("api/version"));
|
||||
const data = await response.json();
|
||||
return data;
|
||||
}
|
||||
|
||||
export async function apiLogin({ nomor }: { nomor: string }) {
|
||||
const response = await fetch(API_BASE("api/auth/login"), {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ nomor: nomor }),
|
||||
});
|
||||
const data = await response.json();
|
||||
return data;
|
||||
}
|
||||
Reference in New Issue
Block a user