From 5291f96051c414490d4127874774ed746cecbe77 Mon Sep 17 00:00:00 2001 From: ryoaxton2000 Date: Thu, 11 Feb 2021 15:50:24 +0700 Subject: [PATCH] fix metadata error from axios for recent threads, change URL to use API_URL --- src/Threads/RecentThreads.js | 10 +++++----- src/services/api_link.js | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Threads/RecentThreads.js b/src/Threads/RecentThreads.js index 3a4baea..a19c904 100644 --- a/src/Threads/RecentThreads.js +++ b/src/Threads/RecentThreads.js @@ -25,7 +25,7 @@ export default function Topic(props){ useEffect(() => { const fetch = async () => { - const responseThreads = await axios.get(`http://localhost:4000/api/threads/pages/recent/?page=${currentPage}`) + const responseThreads = await axios.get(`${API_URL}/threads/pages/recent/?page=${currentPage}`) setThread(responseThreads.data.data) } fetch() @@ -34,8 +34,8 @@ export default function Topic(props){ useEffect(() => { async function getTotalItems() { - const allThreads = await axios.get(`http://localhost:4000/api/threads/pages/recent/`); - const totalItems = allThreads.metadata.total_data; + const allThreads = await axios.get(`${API_URL}/threads/pages/recent/`); + const totalItems = allThreads.data.metadata.total_data; setTotalItems(totalItems); } getTotalItems(); @@ -48,7 +48,7 @@ export default function Topic(props){ async function getThreadsByPage(pageNumber) { setThread([]); - const threadsList = await axios.get(`http://localhost:4000/api/threads/pages/recent/?page=${pageNumber}`) + const threadsList = await axios.get(`${API_URL}/threads/pages/recent/?page=${pageNumber}`) setThread(threadsList.data.data) } @@ -58,7 +58,7 @@ export default function Topic(props){ thread={thread}> diff --git a/src/services/api_link.js b/src/services/api_link.js index 1a56625..851d0fe 100644 --- a/src/services/api_link.js +++ b/src/services/api_link.js @@ -1,2 +1,2 @@ -export const API_URL = 'https://diskuyapi.herokuapp.com/api' -// export const API_URL = 'http://localhost:4000/api' \ No newline at end of file +// export const API_URL = 'https://diskuyapi.herokuapp.com/api' +export const API_URL = 'http://localhost:4000/api' \ No newline at end of file -- GitLab