Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 5291f960 authored by ryoaxton2000's avatar ryoaxton2000
Browse files

fix metadata error from axios for recent threads, change URL to use API_URL

parent fe53234d
No related branches found
No related tags found
1 merge request!8fix metadata error from axios for recent threads, change URL to use API_URL
......@@ -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}>
</ThreadList>
<Pagination
url="http://localhost:4000/api/threads/pages/recent"
url="${API_URL}/threads/pages/recent"
changePage={changePage}
totalItems={totalItems}
/>
......
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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment