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 7
7
"test" : " echo \" Error: no test specified\" && exit 1" ,
8
8
"build" : " webpack" ,
9
9
"lint" : " eslint" ,
10
- "start" : " webpack-dev-server"
10
+ "start" : " webpack-dev-server --progress "
11
11
},
12
12
"keywords" : [],
13
13
"author" : " " ,
18
18
"@babel/preset-env" : " ^7.7.4" ,
19
19
"babel-loader" : " ^8.0.6" ,
20
20
"clean-webpack-plugin" : " ^3.0.0" ,
21
+ "connect-api-mocker" : " ^1.7.0" ,
21
22
"css-loader" : " ^3.2.0" ,
22
23
"eslint" : " ^6.7.2" ,
23
24
"file-loader" : " ^5.0.2" ,
28
29
"webpack" : " ^4.41.2" ,
29
30
"webpack-cli" : " ^3.3.10" ,
30
31
"webpack-dev-server" : " ^3.9.0"
32
+ },
33
+ "dependencies" : {
34
+ "axios" : " ^0.19.0"
31
35
}
32
36
}
Original file line number Diff line number Diff line change
1
+ import axios from 'axios'
2
+
1
3
export 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 ;
15
8
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 ;
18
12
} ,
19
13
20
14
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'
15
2
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 ;
22
7
}
23
8
}
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'
17
2
18
3
export 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 ;
25
7
}
26
8
}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ const path = require('path')
2
2
const HtmlWebpackPlugin = require ( 'html-webpack-plugin' )
3
3
const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' )
4
4
const { CleanWebpackPlugin } = require ( 'clean-webpack-plugin' )
5
+ const apiMocker = require ( 'connect-api-mocker' ) ;
5
6
6
7
module . exports = {
7
8
mode : 'development' ,
@@ -13,7 +14,27 @@ module.exports = {
13
14
path : path . resolve ( './dist' ) ,
14
15
} ,
15
16
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 ,
16
36
} ,
37
+ watch : false ,
17
38
module : {
18
39
rules : [
19
40
{
You can’t perform that action at this time.
0 commit comments