Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import axios from 'axios';
- import { useDispatch } from 'react-redux';
- class Request() {
- constructor(){
- this.init()
- }
- init(){
- axios.interceptors.response.use({ data, status }) => {
- if(status === 204){
- const dispatch = useDispatch();
- dispatch({type: 'SOMETHING_CREATED', alert: 'Created');
- }
- },
- ({ error }) => {
- const dispatch = useDispatch();
- dispatch({type: 'SOMETHING_WRONG', alert: 'Not created');
- })
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment