feat: humas service
This commit is contained in:
parent
2267ffcba9
commit
15e68f809d
|
|
@ -8,8 +8,20 @@ import 'swiper/css/pagination';
|
|||
import { Autoplay, Pagination, Navigation } from 'swiper/modules';
|
||||
import Link from 'next/link';
|
||||
import GPRKominfo from '../SocialMedia/GprKominfo';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { getListArticle } from '@/service/article';
|
||||
|
||||
export default function HeaderNews() {
|
||||
const [article, setArticle] = useState();
|
||||
|
||||
useEffect(() => {
|
||||
async function getArticle() {
|
||||
const response = await getListArticle();
|
||||
console.log("res", response?.data?.data);
|
||||
}
|
||||
getArticle();
|
||||
}, []);
|
||||
|
||||
const newsData = [
|
||||
{
|
||||
id: 1,
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ export default function NavbarHumas() {
|
|||
</DropdownMenu>
|
||||
</Dropdown>
|
||||
</div>
|
||||
<div><Link href="/portal-ppid">Portal PPID</Link></div>
|
||||
<div><Link href="http://103.82.242.92:5000/" target='_blank'>Portal PPID</Link></div>
|
||||
<div>
|
||||
<Dropdown className='dark:bg-[#1F1A17]'>
|
||||
<NavbarItem>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
import { httpGet } from "./http-config/axios-base-service";
|
||||
|
||||
export async function getListArticle() {
|
||||
const headers = {
|
||||
"content-type": "application/json",
|
||||
};
|
||||
return await httpGet(`/articles`, headers);
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
import axiosBaseInstance from "./http-base-service";
|
||||
|
||||
export async function httpPost(pathUrl: any, headers: any, data?: any) {
|
||||
const response = await axiosBaseInstance
|
||||
.post(pathUrl, data, { headers })
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
export async function httpGet(pathUrl: any, headers: any) {
|
||||
const response = await axiosBaseInstance
|
||||
.get(pathUrl, { headers })
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
return error.response;
|
||||
});
|
||||
console.log("Response base svc : ", response);
|
||||
if (response?.status == 200 || response?.status == 201) {
|
||||
return {
|
||||
error: false,
|
||||
message: "success",
|
||||
data: response?.data,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
error: true,
|
||||
message: response?.data?.message || response?.data || null,
|
||||
data: null,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
import axios from "axios";
|
||||
|
||||
const baseURL = "http://103.82.242.92:8888";
|
||||
|
||||
const axiosBaseInstance = axios.create({
|
||||
baseURL,
|
||||
headers: {
|
||||
"content-type": "application/json",
|
||||
},
|
||||
});
|
||||
|
||||
export default axiosBaseInstance;
|
||||
Loading…
Reference in New Issue