Skip to content

Commit

Permalink
Merge pull request #55 from Soongsil-Developers/practiceToken
Browse files Browse the repository at this point in the history
article에 토큰줘서 문제 해결 (연습한 거)
  • Loading branch information
hoyyChoi authored Sep 14, 2022
2 parents 7afffdf + 4bd3695 commit 648a8e7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/component/Article/ShowComment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const ShowComment = () => {
.catch((err) => {
console.log(err);
});
}, []);
}, [comments]);

return (
<div className="row">
Expand Down
1 change: 1 addition & 0 deletions src/component/Article/WriteCommet.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const WriteCommet = () => {
postComment(slug,{body},{user})
.then(res=>{
console.log(res)
//rerender 되면서 코멘트 부분이 추가됨. 페이지 전환
}).catch(err=>{
console.log(err)
})
Expand Down
5 changes: 3 additions & 2 deletions src/component/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import React from 'react'
import ArticleList from './ArticleList'
import Populartags from './Populartags'
import { useRecoilValue } from 'recoil'
import { authState } from '../atoms/auth'
import { authState, userState } from '../atoms/auth'
import { useEffect,useState } from 'react'
import { getArticles } from '../remote/index'

const Home = () => {
let [articleData,setArticleData] = useState([])
const auth = useRecoilValue(authState)
const user = useRecoilValue(userState)

useEffect(()=>{
getArticles('Gerome')
getArticles({user})
.then(res=>{
setArticleData(res.data.articles)
}).catch(err=>{
Expand Down
3 changes: 2 additions & 1 deletion src/component/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ import ArticleList from './ArticleList'
const Profile = () => {

const profile = useRecoilValue(profileState)
const user = useRecoilValue(userState)
let [articleData,setArticleData] = useState([])

useEffect(()=>{
getArticles(profile.username)
getArticles(profile.username,{user})
.then(res=>{
setArticleData(res.data.articles)

Expand Down
2 changes: 1 addition & 1 deletion src/remote/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const postRegisterUser=(user)=>conduitAxios.post('/users',{user});
}}
*/

const getArticles = (author) => conduitAxios.get(`/articles/?author=${author}&limit=20&offset=0`)
const getArticles = ({user}) => conduitAxios.get(`/articles?limit=30&offset=0`,{headers:{authorization:`Bearer ${user.token}`}})

/**
@param {{article: {
Expand Down

0 comments on commit 648a8e7

Please sign in to comment.