to master

This commit is contained in:
unknown
2025-01-29 18:51:52 +07:00
parent dbcd5a736a
commit 62162ff8e0
3 changed files with 33 additions and 26 deletions

View File

@ -9,11 +9,13 @@ const headers = {
if (token) headers["Authorization"] = `Bearer ${token}`;
const instance = axios.create({
baseURL: 'https://api.telkomcel.tl/tpay-stg-dash-api/',
baseURL: `http://127.0.0.1:4003`,
// baseURL: 'https://api.telkomcel.tl/tpay-stg-dash-api/',
headers: headers
})
export async function fetchApi(path, method, data, params) {
try {
let query = params || {};
query.token = token
let response = await instance({
@ -23,4 +25,7 @@ export async function fetchApi(path, method, data, params) {
params: query
});
return response
} catch (error) {
alert(error.message)
}
}

View File

@ -18,6 +18,7 @@ const LoginPage = () => {
if (username && password) {
// GET CREDIENTIAL
let user = await fetchApi('/api/login', 'POST', { username, password });
if (user) {
if (user.data && user.data.data) {
let resUserLogin = user.data.data;
console.log('resUserLogin', resUserLogin);
@ -32,11 +33,13 @@ const LoginPage = () => {
} else {
alert(user.response.data.message);
}
}
} else {
alert("Please fill in both fields.");
}
} catch (error) {
alert(error.response.data.message);
if (error.response) alert(error.response.data.message)
else alert(error.message)
console.log(error);
}
};

View File

@ -86,8 +86,7 @@ function App() {
const location = useLocation();
useEffect(() => {
console.log(roles_list);
console.log(location);
console.log(roles_list, location);
}, [roles_list, location]);