File tree Expand file tree Collapse file tree 8 files changed +114
-60
lines changed Expand file tree Collapse file tree 8 files changed +114
-60
lines changed Original file line number Diff line number Diff line change 1+ [
2+ {
3+ "keyword" : " 검색기록2" ,
4+ "date" : " 12.03"
5+ },
6+ {
7+ "keyword" : " 검색기록1" ,
8+ "date" : " 12.02"
9+ },
10+ {
11+ "keyword" : " 검색기록0" ,
12+ "date" : " 12.01"
13+ }
14+ ]
Original file line number Diff line number Diff line change 1+ [{
2+ "id" : 1 ,
3+ "name" : " [버거] 치즈버거처럼 생긴 새우버거" ,
4+ "image" : " https://images.unsplash.com/photo-1547584370-2cc98b8b8dc8?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
5+ }, {
6+ "id" : 2 ,
7+ "name" : " [샐러드] 맛있는 색깔의 콥셀러드" ,
8+ "image" : " https://images.unsplash.com/photo-1512621776951-a57141f2eefd?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60"
9+ }, {
10+ "id" : 3 ,
11+ "name" : " [피자] 썸네일 주소가 잘못된 상품" ,
12+ "image" : " http://foo.bar/image.jpg"
13+ }]
Original file line number Diff line number Diff line change 77 "test" : " echo \" Error: no test specified\" && exit 1" ,
88 "build" : " webpack" ,
99 "lint" : " eslint" ,
10- "start" : " webpack-dev-server"
10+ "start" : " webpack-dev-server --progress "
1111 },
1212 "keywords" : [],
1313 "author" : " " ,
1818 "@babel/preset-env" : " ^7.7.4" ,
1919 "babel-loader" : " ^8.0.6" ,
2020 "clean-webpack-plugin" : " ^3.0.0" ,
21+ "connect-api-mocker" : " ^1.7.0" ,
2122 "css-loader" : " ^3.2.0" ,
2223 "eslint" : " ^6.7.2" ,
2324 "file-loader" : " ^5.0.2" ,
2829 "webpack" : " ^4.41.2" ,
2930 "webpack-cli" : " ^3.3.10" ,
3031 "webpack-dev-server" : " ^3.9.0"
32+ },
33+ "dependencies" : {
34+ "axios" : " ^0.19.0"
3135 }
3236}
Original file line number Diff line number Diff line change 1+ import axios from 'axios'
2+
13export default {
2- data : [ {
3- keyword : '검색기록2' ,
4- date : '12.03'
5- } ,
6- {
7- keyword : '검색기록1' ,
8- date : '12.02'
9- } ,
10- {
11- keyword : '검색기록0' ,
12- date : '12.01'
13- } ,
14- ] ,
4+ data : [ ] ,
5+
6+ async list ( ) {
7+ if ( this . data . length ) return this . data ;
158
16- list ( ) {
17- return Promise . resolve ( this . data )
9+ const result = await axios . get ( '/api/history' )
10+ this . data = result . data ;
11+ return this . data ;
1812 } ,
1913
2014 add ( keyword = '' ) {
Original file line number Diff line number Diff line change 1- export default {
2- data : [ {
3- keyword : '이탈리아'
4- } ,
5- {
6- keyword : '세프의요리'
7- } ,
8- {
9- keyword : '제철'
10- } ,
11- {
12- keyword : '홈파티'
13- }
14- ] ,
1+ import axios from 'axios'
152
16- list ( ) {
17- return new Promise ( res => {
18- setTimeout ( ( ) => {
19- res ( this . data )
20- } , 200 )
21- } )
3+ export default {
4+ async list ( ) {
5+ const result = await axios . get ( '/api/keywords' ) ;
6+ return result . data ;
227 }
238}
Original file line number Diff line number Diff line change 1- const data = [ {
2- id : 1 ,
3- name : '[버거] 치즈버거처럼 생긴 새우버거' ,
4- image : 'https://images.unsplash.com/photo-1547584370-2cc98b8b8dc8?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'
5- } ,
6- {
7- id : 2 ,
8- name : '[샐러드] 맛있는 색깔의 콥셀러드' ,
9- image : 'https://images.unsplash.com/photo-1512621776951-a57141f2eefd?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=800&q=60'
10- } ,
11- {
12- id : 3 ,
13- name : '[피자] 썸네일 주소가 잘못된 상품' ,
14- image : 'http://foo.bar/image.jpg'
15- }
16- ]
1+ import axios from 'axios'
172
183export default {
19- list ( ) {
20- return new Promise ( res => {
21- setTimeout ( ( ) => {
22- res ( data )
23- } , 200 ) ;
24- } )
4+ async list ( ) {
5+ const result = await axios . get ( '/api/search' ) ;
6+ return result . data ;
257 }
268}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const path = require('path')
22const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
33const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' )
44const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' )
5+ const apiMocker = require ( 'connect-api-mocker' ) ;
56
67module . exports = {
78 mode : 'development' ,
@@ -13,7 +14,27 @@ module.exports = {
1314 path : path . resolve ( './dist' ) ,
1415 } ,
1516 devServer : {
17+ contentBase : './dist' ,
18+ publicPath : '/' ,
19+ open : true ,
20+ before : ( app , server , compiler ) => {
21+ app . get ( '/api/keywords' , ( req , res ) => {
22+ res . json ( [
23+ { keyword : '이탈리아' } ,
24+ { keyword : '세프의요리' } ,
25+ { keyword : '제철' } ,
26+ { keyword : '홈파티' }
27+ ] )
28+ } )
29+ app . use ( apiMocker ( '/api' , 'mocks/api' ) )
30+ } ,
31+ host : 'dev.domain.com' ,
32+ stats : 'errors-only' ,
33+ overlay : true ,
34+ port : 8081 ,
35+ historyApiFallback : true ,
1636 } ,
37+ watch : false ,
1738 module : {
1839 rules : [
1940 {
You can’t perform that action at this time.
0 commit comments