Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Middleware, MiddlewareAPI, Dispatch, Action } from "redux"
- export const logger: Middleware = <S>(api: MiddlewareAPI<S>) => (
- next: Dispatch<S>
- ) => <A extends Action>(action: A): A => {
- console.log("Before")
- const result = next(action)
- if (action.type.HTTPStatus) {
- console.log("HERE IS AN ERROR")
- }
- console.log("After", api.getState())
- return result
- }
- export const getTelevisionChannels = (televisionIds: string[]) => async (
- dispatch: Dispatch<AppState>
- ) => {
- try {
- const response = await API.post(
- "/Channels/querys/status",
- { body: JSON.stringify({ televisionIds }) },
- true,
- dispatch
- )
- const televisionChannels = await response.json()
- televisionChannels.map((televisionChannel: any) =>
- dispatch(
- getChannelsSuccess(televisionChannel.televisionId, televisionChannel.channels)
- )
- )
- } catch (err) {
- dispatch(push("/404"))
- console.log(err)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement