diff --git a/diskuy/package.json b/diskuy/package.json index 3d5998a4b149bf319941576bf9b5c2259fb70d14..b05d755b716444a648e4cf0ccb3c0ad8bccb5fb3 100644 --- a/diskuy/package.json +++ b/diskuy/package.json @@ -15,7 +15,7 @@ "web-vitals": "^0.2.4" }, "scripts": { - "start": "set PORT=3000 && react-scripts start", + "start": "node server/server.js", "build": "react-scripts build", "test": "react-scripts test", "eject": "react-scripts eject" diff --git a/diskuy/src/Topic.js b/diskuy/src/Topic.js index 894f830cfc0cbd060bcef698add037f9d93bba22..a45bff0e6d4a44bd516fbbbe9b492ace1fa6647e 100644 --- a/diskuy/src/Topic.js +++ b/diskuy/src/Topic.js @@ -11,19 +11,19 @@ export default function Topic(props){ useEffect(() => { const fetch = async () => { - const responseThreads = await axios.get(`${API_URL}/threads/`) - const responseTopics = await axios.get(`${API_URL}/topics`) + try { + const responseThreads = await axios.get(`${API_URL}/threads/`) + const responseTopics = await axios.get(`${API_URL}/topics`) - const topic = responseTopics.data.data.find(topic => topic.name === topicParam).id - const threads = responseThreads.data.data.filter(thread => thread.topic_id === topic) - const sortedThreads = threads.sort((a, b) => { + const topic = responseTopics.data.data.find(topic => topic.name === topicParam).id + const threads = responseThreads.data.data.filter(thread => thread.topic_id === topic) + const sortedThreads = threads.sort((a, b) => { if (a.id < b.id) return 1 if (a.id > b.id) return -1 return 0 - }) - setThread(sortedThreads) - console.log(threads) - + }) + setThread(sortedThreads) + } catch(error){} } fetch() }, [topicParam])