data.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import APIHandler from "./APIHandler";
  2. import { ARTICLE_CATEGORY_URL, ARTICLE_COMMENTS_URL, ARTICLE_DETAIL_URL, ARTICLE_RECOMMENDATIONS_URL, ARTICLE_SEARCH_URL, MENUS_URL, TRENDING_URL } from "./urls";
  3. /**
  4. * Fetch Trending News via API
  5. * @return {Axios.get()} Get Axios Method for Trending New URL.
  6. */
  7. export const getTrendingNews = () => APIHandler.get(TRENDING_URL)
  8. /**
  9. * Fetch Menu Data via API
  10. * @return {Axios.get} Get Axios Method for Menu URL .
  11. */
  12. export const getMenus = () => APIHandler.get(MENUS_URL)
  13. /**
  14. * Fetch Articles By Specified Category with Pagination
  15. * @param {String} category - Category Name
  16. * @param {number} page - Page Number
  17. * @return {Axios.get} - Get Axios Method for Articles by Category
  18. */
  19. export const getArticlesByCategory = (category,page = 1) => APIHandler.get(ARTICLE_CATEGORY_URL(category,page))
  20. /**
  21. * Fetch Articles By Specified Category with Pagination
  22. * @param {String} category - Category Name
  23. * @param {number} page - Page Number
  24. * @param {String} filters - Additional Filters
  25. * @return {Axios.get} - Get Axios Method for Articles by Search Query
  26. */
  27. export const getArticlesBySearch = (category,page = 1,filters="") => {console.log(ARTICLE_SEARCH_URL(category,page,filters));return APIHandler.get(ARTICLE_SEARCH_URL(category,page,filters))}
  28. /**
  29. * Fetch Article By Slug
  30. * @param {String} slug - Slug Name
  31. * @return {Axios.get} - Get Axios Method for Article by Slug
  32. */
  33. export const getArticleBySlug = (slug) => APIHandler.get(ARTICLE_DETAIL_URL(slug))
  34. /**
  35. * Fetch Comments by Article ID
  36. * @param {String} id - Slug Name
  37. * @return {Axios.get} - Get Axios Method for Comments by Article ID
  38. */
  39. export const getCommentByArticleID = (id) => APIHandler.get(ARTICLE_COMMENTS_URL(id))
  40. /**
  41. * Fetch Recommendations By Article ID
  42. * @param {String} id - Article ID
  43. * @return {Axios.get} - Get Axios Method for Recommendations By Article ID
  44. */
  45. export const getRecommendationByArticleID = (id) => APIHandler.get(ARTICLE_RECOMMENDATIONS_URL(id))
  46. /**
  47. * Fetch Category Data By Article ID
  48. * @param {String} id - Article ID
  49. * @return {Axios.get} - Get Axios Method for Category Data By Article ID
  50. */
  51. export const getCategories = () => APIHandler.get(MENUS_URL)