Skip to content
Snippets Groups Projects
Commit 0a6e502b authored by Chif Gergő's avatar Chif Gergő
Browse files

Add news list client function

parent 7cf04a55
No related branches found
No related tags found
1 merge request!19fix type imports
import Axios, { AxiosRequestConfig } from 'axios';
import { INews } from '../types/News';
type NewsQuery = () => Promise<INews[]>;
export type NewsClient = {
news: NewsQuery;
};
const authToken = 'q98g7o6353wl7usv1a36xv6dieso6219';
export function users(config: AxiosRequestConfig): NewsClient {
const axios = Axios.create({
...config,
baseURL: `${config.baseURL}/api/v1/news`,
});
const news: NewsQuery = async (): Promise<INews[]> => {
const { data: response } = await axios.get<INews[]>('/', {
headers: { Authorization: `Bearer ${authToken}` },
});
return response;
};
return {
news,
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment