Skip to content

Commit

Permalink
refector : axios 도입 및 페이지 api 연동 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
devbit4 committed Jan 15, 2024
1 parent fb13045 commit 98c5e61
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,8 @@
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^4.15.1"
},
"dependencies": {
"axios": "^1.6.5"
}
}
6 changes: 4 additions & 2 deletions src/api/getArticle.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import axios from 'axios';

export default async function getArticle(id) {
const res = await fetch('/dbs/articleList.json');
const res = await axios('/dbs/articleList.json');

const data = await res.json();
const data = await res.data;

return data.articles[id];
}
6 changes: 4 additions & 2 deletions src/api/getArticleList.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import axios from 'axios';

export default async function getArticleList() {
const res = await fetch('/dbs/articleList.json');
const res = await axios('/dbs/articleList.json');

const data = await res.json();
const data = await res.data;

return data.articles;
}

0 comments on commit 98c5e61

Please sign in to comment.