-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 거래량 부재로 미체결 처리된 주문이 서버 데이터 갱신에 따라 체결처리 되었을 때 해당 정보를 서버로 부터 GET 하는 로직 구현 - 컴포넌트에 적용하여 fetching 테스트 진행 예정 Issues #122
- Loading branch information
1 parent
e48e4bf
commit 25d4d1b
Showing
1 changed file
with
37 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useQuery, useQueryClient } from "react-query"; | ||
import axios from "axios"; | ||
|
||
const url = "http://ec2-13-125-246-160.ap-northeast-2.compute.amazonaws.com:8080/long-polling/listen"; | ||
|
||
const useGetWaitOrderSuccessInfo = () => { | ||
const queryClient = useQueryClient(); | ||
|
||
const { data, isLoading, isError, refetch } = useQuery("waitOrderSuccess", getWaitOrderSuccessInfo, { | ||
onSuccess: (data) => { | ||
queryClient.invalidateQueries("cash"); | ||
queryClient.invalidateQueries("holdingStock"); | ||
queryClient.invalidateQueries("orderRecord"); | ||
refetch(); | ||
console.log("예약주문 처리 테스트"); | ||
console.log(data); | ||
}, | ||
}); | ||
|
||
return { waitOrderSuccessData: data, waitOrderSuccessLoading: isLoading, waitOrderSuccessError: isError }; | ||
}; | ||
|
||
export default useGetWaitOrderSuccessInfo; | ||
|
||
const getWaitOrderSuccessInfo = async () => { | ||
const accessToken = localStorage.getItem("accessToken"); | ||
const options = { | ||
headers: { | ||
Authorization: `${accessToken}`, | ||
"Content-Type": "application/json", | ||
}, | ||
}; | ||
|
||
const response = await axios.get(url, options); | ||
const orderInfo = await response.data; | ||
return orderInfo; | ||
}; |