Pārlūkot izejas kodu

Article Search URL Entity Added

Savio Fernando 1 gadu atpakaļ
vecāks
revīzija
d88c229866
3 mainītis faili ar 6 papildinājumiem un 4 dzēšanām
  1. 1 1
      src/api/APIHandler.js
  2. 3 2
      src/api/data.js
  3. 2 1
      src/api/urls.js

+ 1 - 1
src/api/APIHandler.js

@@ -3,5 +3,5 @@ import { API_URL_v1} from "./urls";
 
 export default APIHandler = axios.create({
     baseURL: API_URL_v1,
-    timeout: 2000,
+    timeout: 3000,
 })

+ 3 - 2
src/api/data.js

@@ -1,9 +1,10 @@
 import APIHandler from "./APIHandler";
-import { ARTICLE_COMMENTS_URL, ARTICLE_DETAIL_URL, ARTICLE_RECOMMENDATIONS_URL, ARTICLE_SEARCH_URL, MENUS_URL, TRENDING_URL } from "./urls";
+import { ARTICLE_CATEGORY_URL, ARTICLE_COMMENTS_URL, ARTICLE_DETAIL_URL, ARTICLE_RECOMMENDATIONS_URL, ARTICLE_SEARCH_URL, MENUS_URL, TRENDING_URL } from "./urls";
 
 export const getTrendingNews = () =>  APIHandler.get(TRENDING_URL)
 export const getMenus = () => APIHandler.get(MENUS_URL)
-export const getArticlesByCategory = (category,page = 1) => APIHandler.get(ARTICLE_SEARCH_URL(category,page))
+export const getArticlesByCategory = (category,page = 1) => APIHandler.get(ARTICLE_CATEGORY_URL(category,page))
+export const getArticlesBySearch = (category,page = 1) => APIHandler.get(ARTICLE_SEARCH_URL(category,page))
 export const getArticleBySlug = (slug) => APIHandler.get(ARTICLE_DETAIL_URL(slug))
 export const getCommentByArticleID = (id) => APIHandler.get(ARTICLE_COMMENTS_URL(id))
 export const getRecommendationByArticleID = (id) => APIHandler.get(ARTICLE_RECOMMENDATIONS_URL(id))

+ 2 - 1
src/api/urls.js

@@ -10,7 +10,8 @@ export const API_URL_v2 = BASE_URL + "/api/v2/"
 export const ARTICLE_URL = `article/search/?domain=${DEFAULT_DOMAIN}`
 export const TRENDING_URL = `trending/?domain=${DEFAULT_DOMAIN}`
 export const MENUS_URL =  `menus/?domain=${DEFAULT_DOMAIN}`
-export const ARTICLE_SEARCH_URL = (category_type,page = 1) =>  `article/search/?domain=${DEFAULT_DOMAIN}&category=${category_type}&page=${page}`
+export const ARTICLE_CATEGORY_URL = (category_type,page = 1) =>  `article/search/?domain=${DEFAULT_DOMAIN}&category=${category_type}&page=${page}`
+export const ARTICLE_SEARCH_URL = (search_text,page = 1) =>  `article/search/?domain=${DEFAULT_DOMAIN}&q=${search_text}&page=${page}`
 export const ARTICLE_DETAIL_URL = (slug) => `articles/${slug}/?domain=${DEFAULT_DOMAIN}`
 export const ARTICLE_COMMENTS_URL = (id) => `comment/?article_id=${id}`
 export const ARTICLE_RECOMMENDATIONS_URL = (id) => `articles/${id}/recommendations`