23 lines
642 B
TypeScript
23 lines
642 B
TypeScript
import axios from "axios";
|
|
import { getCookie } from "cookies-next";
|
|
axios.defaults.baseURL = process.env.NEXT_PUBLIC_BASE_URL_APP;
|
|
|
|
axios.interceptors.request.use(function (config) {
|
|
const token = getCookie("Shahrbin_Token");
|
|
config.headers.Authorization = token ? `Bearer ${token}` : "";
|
|
return config;
|
|
});
|
|
|
|
// Get News
|
|
export async function getNews() {
|
|
const data = await axios.get(`/api/CitizenNews/News`);
|
|
return data.data;
|
|
}
|
|
|
|
// Get News {ID}
|
|
export async function getSingleNews(id: number) {
|
|
// export async function getSingleNews(id : any) {
|
|
const data = await axios.get(`/api/CitizenNews/${id}`);
|
|
return data.data;
|
|
}
|