Skip to content

Commit

Permalink
fix(api): added console logs
Browse files Browse the repository at this point in the history
  • Loading branch information
HoseaCodes committed Mar 20, 2022
1 parent 27360a1 commit 4b69046
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/API/ArticlesAPI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -28,4 +30,4 @@ function ArticlesAPI() {

}

export default ArticlesAPI;
export default ArticlesAPI;
4 changes: 3 additions & 1 deletion src/API/ProductsAPI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
7 changes: 4 additions & 3 deletions src/API/UserAPI.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4b69046

Please sign in to comment.