From 4b69046bee444c4ee669c240da98bfdc545b746b Mon Sep 17 00:00:00 2001 From: hosead6168 Date: Sun, 20 Mar 2022 03:15:12 -0500 Subject: [PATCH] fix(api): added console logs --- src/API/ArticlesAPI.jsx | 4 +++- src/API/ProductsAPI.jsx | 4 +++- src/API/UserAPI.jsx | 7 ++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/API/ArticlesAPI.jsx b/src/API/ArticlesAPI.jsx index f7613da9..4ffb402e 100755 --- a/src/API/ArticlesAPI.jsx +++ b/src/API/ArticlesAPI.jsx @@ -11,6 +11,8 @@ function ArticlesAPI() { useEffect(() => { const getArticles = async () => { const res = await axios.get(`/api/articles`) + console.log(res.data.articles, 'from front-end api articles') + console.log(res.data.location, 'pulled location') setArticles(res.data.articles) setResult(res.data.result) } @@ -28,4 +30,4 @@ function ArticlesAPI() { } -export default ArticlesAPI; \ No newline at end of file +export default ArticlesAPI; diff --git a/src/API/ProductsAPI.jsx b/src/API/ProductsAPI.jsx index da20870c..afb9ea5a 100644 --- a/src/API/ProductsAPI.jsx +++ b/src/API/ProductsAPI.jsx @@ -12,8 +12,10 @@ function ProductsAPI() { useEffect(() => { const getProducts = async () => { - const res = await axios.get(`http://localhost:3001/api/products?limit=${page * 9}&${sort}&title[regex]=${search}`) + const res = await axios.get(`/api/products?limit=${page * 9}&${sort}&title[regex]=${search}`) // const res = await axios.get("/api/products") + console.log(res.data.products, 'from front-end api products') + console.log(res.data.location, 'pulled location') setProducts(res.data.products) setResult(res.data.result) } diff --git a/src/API/UserAPI.jsx b/src/API/UserAPI.jsx index 277d06aa..08bfcf78 100644 --- a/src/API/UserAPI.jsx +++ b/src/API/UserAPI.jsx @@ -32,11 +32,12 @@ function UserAPI(token) { const res = await axios.get("/api/user/info", { headers: { Authorization: token }, }); - console.log(res.data._id) + console.log(res.data.users, 'from front-end api user') + console.log(res.data.location, 'pulled location') setIsLoggedIn(true); isAuthenticated(true); - setUser(res.data); - res.data.role === 1 ? setIsAdmin(true) : setIsAdmin(false); + setUser(res.data.users); + res.data.users.role === 1 ? setIsAdmin(true) : setIsAdmin(false); } catch (err) { alert(err.response.data.msg);