-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
159 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { createSlice } from "@reduxjs/toolkit"; | ||
|
||
const initialState = { | ||
products: [], // 초기 상태는 빈 배열로 설정 | ||
}; | ||
|
||
const pOrderListReducer = createSlice({ | ||
name: 'pOrderList', | ||
initialState, | ||
reducers: { | ||
fetchProductsSuccess: (state, action) => { | ||
state.products = action.payload; | ||
console.log("reducer:"+JSON.stringify(state.products)); | ||
|
||
}, | ||
} | ||
}); | ||
|
||
export const { fetchProductsSuccess } = pOrderListReducer.actions; | ||
export default pOrderListReducer.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// 액션 타입 정의 | ||
import axios from "axios"; | ||
import { fetchProductsSuccess } from '../slices/pOrderListReducer' | ||
; | ||
|
||
|
||
// 비동기로 products 데이터를 가져오는 액션 크리에이터 함수 | ||
export const fetchProducts = () => async (dispatch) => { | ||
try { | ||
const response = await axios.get("http://localhost:8888/api/porder/list"); | ||
const products = response.data; | ||
console.log(products) | ||
console.log("thunk: "+products); | ||
dispatch(fetchProductsSuccess(products)); | ||
} catch (error) { | ||
console.error('Error fetching products:', error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.